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½¥½¥µØ³öÏÖ²»¿°ÖظºµÄÇé¿ö£ºÁ¬½ÓºÜÂýÉõÖÁå´»ú£¬ÓÚÊǾÍÓаÑÊý¾Ý´ÓMYSQLǨµ½ORACLEµÄÐèÇó£¬Ó¦ÓóÌÐòÒ²ÒªÏàÓ¦×öһЩÐ޸ġ£±¾ÈË×ܽá³öÒÔϼ¸µã×¢ÒâÊÂÏϣÍû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1.×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ´¦Àí
MYSQLÓÐ ......
mysql ¿ÉÒÔͨ¹ý×Ó²éѯµÃµ½ÒªÉ¾³ýµÄ¼Ç¼Ìõ¼þ£¬È»ºóͨ¹ý×Ó²éѯµÃ½á¹ûÆ¥ÅäҪɾ³ýµÄ¼Ç¼¡£µ«ÊÇ mysql ²»ÄÜÖ±½Óɾ³ý×Ó²éѯ±íÖеÄÊý¾Ý£¬±ØÐëͨ¹ýÒ»¸öÁÙʱ±íÀ´½â¾ö¡£ÀýÈ磺
delete from t_transaction where exists
(select d.* from t_ti_category a,t_category b,t_ ......
MySql³£ÓÃÃüÁî
¡¾MySqlÃüÁî´°¿ÚÆô¶¯£ºÇëÖ´ÐÐ\bin\mysql.exe¡¿
1:ʹÓÃSHOWÓï¾äÕÒ³öÔÚ·þÎñÆ÷Éϵ±Ç°´æÔÚʲôÊý¾Ý¿â£º
mysql> SHOW DATABASES;
2:´´½¨Ò»¸öÊý¾Ý¿âMYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3:Ñ¡ÔñÄãËù´´½¨µÄÊý¾Ý¿â
mysql> USE MYSQLDATA; (°´»Ø³µ¼ü³öÏÖDatabase changed Ê±Ë ......
mysql ÃüÁîѧϰ£º
1. mysql -uroot ;
2.mysql -h ip -ubusiusr -pbusiusr newdrmdb;
3.show databases ; //ÏÔʾËùÓеÄÊý¾Ý¿â ;
4.show tables ; ......
ÎÊÌ⣺
1¡¢Êý¾Ý¿âĬÈϵÄ×Ö·û¼¯ÉèÖÃΪUTF-8£»
2¡¢Í¨¹ýibatis¶ÁдÊý¾ÝÖÐÎÄÕý³££»
3¡¢µ«ÊÇÓÃwindowsÃüÁîÐÐÖ´ÐÐselectÓï¾äÖÐÎÄÏÔʾÂÒÂë¡£
½â¾ö£º
Êý¾Ý¿âÓû§µÇ¼ʱ²ÎÊýÉ趨×Ö·û¼¯£º
mysql --default-character-set=gb2312 -u ̞ -p
£¨¹À¼ÆºÍwindowsµÄcmdÃüÁîÐÐÓйأ© ......