mysql³£ÓÃÃüÁî
1¡¢MySQL³£ÓÃÃüÁî
create database name; ´´½¨Êý¾Ý¿â
use databasename; Ñ¡ÔñÊý¾Ý¿â
drop database name Ö±½Óɾ³ýÊý¾Ý¿â£¬²»ÌáÐÑ
show tables; ÏÔʾ±í
describe tablename; ±íµÄÏêϸÃèÊö
select ÖмÓÉÏdistinctÈ¥³ýÖØ¸´×Ö¶Î
mysqladmin drop databasename ɾ³ýÊý¾Ý¿âǰ£¬ÓÐÌáʾ¡£
ÏÔʾµ±Ç°mysql°æ±¾ºÍµ±Ç°ÈÕÆÚ
select version(),current_date;
2¡¢ÐÞ¸ÄmysqlÖÐrootµÄÃÜÂ룺
shell>mysql -u root -p
mysql> update user set password=password(”xueok654123″) where user=’root’;
mysql> flush privileges //Ë¢ÐÂÊý¾Ý¿â
mysql>use dbname£» ´ò¿ªÊý¾Ý¿â£º
mysql>show databases; ÏÔʾËùÓÐÊý¾Ý¿â
mysql>show tables; ÏÔʾÊý¾Ý¿âmysqlÖÐËùÓÐµÄ±í£ºÏÈuse mysql£»È»ºó
mysql>describe user; ÏÔʾ±ímysqlÊý¾Ý¿âÖÐuser±íµÄÁÐÐÅÏ¢£©£»
3¡¢grant
´´½¨Ò»¸ö¿ÉÒÔ´ÓÈκεط½Á¬½Ó·þÎñÆ÷µÄÒ»¸öÍêÈ«µÄ³¬¼¶Óû§£¬µ«ÊDZØÐëʹÓÃÒ»¸ö¿ÚÁîsomething×öÕâ¸ö
mysql> grant all privileges on *.* to user@localhost identified by ’something’ with
Ôö¼ÓÐÂÓû§
¸ñʽ£ºgrant select on Êý¾Ý¿â.* to Óû§Ãû@µÇ¼Ö÷»ú identified by “ÃÜÂë”
GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY ’something’ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO monty@”%” IDENTIFIED BY ’something’ WITH GRANT OPTION;
ɾ³ýÊÚȨ£º
mysql> revoke all privileges on *.* from root@”%”;
mysql> delete from user where user=”root” and host=”%”;
mysql> flush privileges;
´´½¨Ò»¸öÓû§customÔÚÌØ¶¨¿Í»§¶Ëit363.comµÇ¼£¬¿É·ÃÎÊÌØ¶¨Êý¾Ý¿âfangchandb
mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by ‘ passwd’
ÖØÃüÃû±í:
mysql > alter table t1 rename t2;
4¡¢mysqldump
±¸·ÝÊý¾Ý¿â
shell> mysqldump -h host -u root -p dbname >dbname_backup.sql
»Ö¸´Êý¾Ý¿â
shell> mysqladmin -h myhost -u root -p create dbname
shell> mysqldump -h host -u root -p dbname < dbname_backup.sql
Èç¹ûÖ»Ïëж³ö½¨±íÖ¸ÁÔòÃüÁîÈçÏ£º
shell> mysqladmin -u root -p
Ïà¹ØÎĵµ£º
# tar -zxvf mysql-5.0.45.tar.gz -C /usr/src/
# cd /usr/src/mysql-5.0.45
# ./configure --prefix=/usr/local/mysql --with-charset=gbk
--localstatedir=/usr/local/mysql/data
# make
# make install
# groupadd mysql
# useradd mysql -g mysql
# cd /usr/local/mysql/bin
# ./mysql_install_db --user=mys ......
MySQL5.X¶¼ÒѾ·¢²¼ºÃ¾ÃÁË£¬µ«ÊÇ»¹ÓкܶàÈËÈÏΪMySQLÊDz»Ö§³ÖÊÂÎñ´¦ÀíµÄ£¬Õâ²»µÃ²»¹ÖËûÃÇÊǹª¹ÑÎŵ쬯äʵ£¬Ö»ÒªÄãµÄMySQL°æ±¾ Ö§³ÖBDB»òInnoDB±íÀàÐÍ£¬ÄÇôÄãµÄMySQL¾Í¾ßÓÐÊÂÎñ´¦ÀíµÄÄÜÁ¦¡£ÕâÀïÃæ£¬ÓÖÒÔInnoDB±íÀàÐÍÓõÄ×î¶à£¬ËäÈ»ºóÀ´·¢ÉúÁËÖîÈçOracleÊÕ ¹ºInnoDBµÈÁîMySQL²»Ë¬µÄÊÂÇ飬µ«ÄÇЩÉÌÒµÉϵĶ·ÕùÓë¼¼ÊõÎ޹أ¬Ï ......
.¹Ø±ÕÏÖÓÐmysql
.²»¼ÓÔØgrant_tables¶ø½øÈëmysql
D:\>mysqld-nt --skip-grant-tables OR mysqld_safe --skip-grant-tables
.пªÒ»¸öcmd´°¿Ú,È»ºó°´ÏÂÃæÖ´ÐÐ
D:\>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.27-community-nt ......
1¡¢ÔÚÅäÖÃmysqlʵÀýµÄÓïÑÔÑ¡Ïîʱ£¬Ñ¡Ôñutf-8
2¡¢ÔÚhtml,phpÒ³ÃæÖÐ ¼ÓÉÏ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />£¬Èç¹û²»ÐÐÔÙÔÚ phpÎļþ Æðʼ´¦¼Ó header("Content-Type:text/html;charset=utf-8");
3¡¢ÔÚphpÖÐ×öÊý¾Ý¿âÁ¬½Óʱ£¬ÎÒÓõÄʱpdoµÄÐÎʽ£¬Ë ......