MySQL Basic Knowledge
MySQL°æ±¾: Server version: 5.1.44 Source distribution
ÐÞ¸ÄrootÃÜÂë
Èç¹ûûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂëÉèΪ"123456"
$ mysqladmin -u root password 123456
Èç¹ûÓÐÃÜÂëʹÓÃÏÂÃæµÄÃüÁî, ½«ÃÜÂë¸ÄΪ"123456"
$ mysqladmin -u root -p password 123456
Enter password:
Óû§ÕË»§¹ÜÀí
Ìí¼ÓÕË»§:
http://dev.mysql.com/doc/refman/5.1/zh/database-administration.html#user-account-management
Ìáµ½µÄ·½·¨²»ÊÊÓÃ:
mysql>
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
¸ù¾Ýhttp://dev.mysql.com/doc/refman/5.1/en/adding-users.htmlËù˵, ÒªÏÈcreate user, È»ºóÔÙʹÓÃgrant, ¸ù¾Ý³¢ÊÔ, ÔÚmysqlÖÐ, Óï¾ä²»Çø·Ö´óСд. ÕýÈ·µÄ·½·¨ÈçÏÂ:
mysql> create user 'frank'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'frank'@'localhost' INDENTIFIED BY '123456' WITH GRANT OPTION;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INDENTIFIED BY '123456' WITH GRANT OPTION' at line 1
mysql> GRANT ALL PRIVILEGES ON *.* TO 'frank'@'localhost' WITH GRANT OPTION;Query OK, 0 rows affected (0.00 sec)
mysql>
ÒÔÉÏÓï¾ä´´½¨ÁËÃûΪ"frank"µÄÓû§, ÃÜÂëΪ"123456", ¸ÃÓû§Îª³¬¼¶Óû§, Ö»ÄÜ´Ólocal hostµÇ¼.
mysql> create user 'frank'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'frank'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql>
ÉÏÃæµÄÓï¾ä´´½¨ÁËÃûΪ"frank"µÄ³¬¼¶Óû§, ÃÜÂëΪ"123456", ¸ÃÓû§¿ÉÒÔ´ÓÈÎÒâÖ÷»úµÇ¼. ´´½¨localhostµÄ"frank"Óû§ÊDZØÐëµÄ:
It is necessary to have both accounts for
monty
to be able to connect from anywhere
as monty
. Without the
localhost
account, the anonymous-user
account for localhost
that is created by
mysql_install_db
would take precede
Ïà¹ØÎĵµ£º
mysql ¿ÉÒÔͨ¹ý×Ó²éѯµÃµ½ÒªÉ¾³ýµÄ¼Ç¼Ìõ¼þ£¬È»ºóͨ¹ý×Ó²éѯµÃ½á¹ûÆ¥ÅäҪɾ³ýµÄ¼Ç¼¡£µ«ÊÇ mysql ²»ÄÜÖ±½Óɾ³ý×Ó²éѯ±íÖеÄÊý¾Ý£¬±ØÐëͨ¹ýÒ»¸öÁÙʱ±íÀ´½â¾ö¡£ÀýÈ磺
delete from t_transaction where exists
(select d.* from t_ti_category a,t_category b,t_ ......
mysql ÃüÁîѧϰ£º
1. mysql -uroot ;
2.mysql -h ip -ubusiusr -pbusiusr newdrmdb;
3.show databases ; //ÏÔʾËùÓеÄÊý¾Ý¿â ;
4.show tables ; ......
¹Ø¼ü×Ö: mysql grant
±¾ÎÄʵÀý£¬ÔËÐÐÓÚ MySQL 5.0 ¼°ÒÔÉϰ汾¡£
MySQL ¸³ÓèÓû§È¨ÏÞÃüÁîµÄ¼òµ¥¸ñʽ¿É¸ÅÀ¨Îª£º
grant ȨÏÞ on Êý¾Ý¿â¶ÔÏó to Óû§
Ò»¡¢grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû¡£
grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user ......
×î½üÏëÔÚ·þÎñÆ÷ÉÏÊÔÊÔMySQL5.1µÄ·ÖÇø£¬ÓÚÊǾÍÏë×Å×°¸öMySQL5.1£¬¾¹ýÍ´¿àµÄÒ»¶Î¾Àúºó£¬ÖÕÓÚÕÒ¸öÏÂÃæ×°¸öºÜºÃµÄ½Ì³Ì£¬ÌûÉÏÀ´±¸Íü¡£
1¡¢MySQLÃâ°²×°°æ/¶þ½øÖưæÈí¼þ£¬²»ÓñàÒ룬ÏÂÔØµØÖ·£º
http://dev.mysql.com/downloads/
Îļþ¸ñʽ£ºMYSQL-VERSION-OS.tar.gz
2¡¢´ ......