¡¡¡¡MySQLÊÇÒ»¸öÕæÕýµÄ¶àÓû§¡¢¶àÏß³ÌSQLÊý¾Ý¿â·þÎñÆ÷¡£MySQLÊÇÒÔÒ»¸ö¿Í»§»ú/·þÎñÆ÷½á¹¹µÄʵÏÖ£¬ËüÓÉÒ»¸ö·þÎñÆ÷ÊØ»¤³ÌÐòmysqldºÍºÜ¶à²»Í¬µÄ¿Í»§³ÌÐòºÍ¿â×é³É¡£ÓÉÓÚÆäÔ´ÂëµÄ¿ª·ÅÐÔ¼°Îȶ¨ÐÔ£¬ÇÒÓëÍøÕ¾Á÷Ðбà?»ÓïÑ?PHPµÄÍêÃÀ½áºÏ£¬ÏÖÔںܶàÕ¾µã¶¼ÀûÓÃÆäµ±×÷ºó¶ËÊý¾Ý¿â£¬Ê¹Æä»ñµÃÁ˹㷺ӦÓᣴ¦ÓÚ°²È«·½ÃæµÄ¿¼ÂÇ£¬ÐèҪΪÿһÓû§¸³ÓÚ¶Ô²»Í¬Êý¾Ý¿âµÄ·ÃÎÊÏÞÖÆ£¬ÒÔÂú×㲻ͬÓû§µÄÒªÇó¡£ÏÂÃæ¾Í·Ö±ðÌÖÂÛ£¬¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢MySQLÐÞ¸ÄÃÜÂë·½·¨×ܽá
¡¡¡¡Ê×ÏÈҪ˵Ã÷Ò»µãµÄÊÇ£ºÒ»°ãÇé¿öÏ£¬ÐÞ¸ÄMySQLÃÜÂëÊÇÐèÒªÓÐmysqlÀïµÄrootȨÏ޵ģ¬ÕâÑùÒ»°ãÓû§ÊÇÎÞ·¨¸ü¸ÄÃÜÂëµÄ£¬³ý·ÇÇëÇó¹ÜÀíÔ±°ïÖúÐ޸ġ£
·½·¨Ò»
¡¡¡¡Ê¹ÓÃphpMyAdmin (ͼÐλ¯¹ÜÀíMySqlÊý¾Ý¿âµÄ¹¤¾ß)£¬ÕâÊÇ×î¼òµ¥µÄ£¬Ö±½ÓÓÃSQLÓï¾äÐÞ¸ÄmysqlÊý¾Ý¿â¿âµÄuser±í£¬²»¹ý±ðÍüÁËʹÓÃPASSWORDº¯Êý£¬²åÈëÓû§ÓÃInsertÃüÁÐÞ¸ÄÓû§ÓÃUpdateÃüÁɾ³ýÓÃDeleteÃüÁî¡£ÔÚ±¾½ÚºóÃæÓÐÊý¾Ý±íuser×ֶεÄÏêϸ½éÉÜ¡£
·½·¨¶þ
ʹÓÃmysqladmin¡£ÊäÈë
mysqladmin -u root -p oldpassword newpasswd
¡¡¡¡Ö´ÐÐÕâ¸öÃüÁîºó£¬ÐèÒªÊäÈërootµÄÔÃÜÂ룬ÕâÑùrootµÄÃÜÂ뽫¸ÄΪnewpasswd¡£Í¬Ñù£¬°ÑÃüÁîÀïµÄroot¸ÄΪÄãµÄÓû§Ãû£¬Äã¾Í¿ÉÒÔ¸ÄÄã×Ô¼ºµÄÃÜÂëÁË¡£ µ±È»Èç¹ûÄãµÄmysqladminÁ¬½Ó²»ÉÏmysql server£¬»òÕßÄãûÓа취ִÐÐmysqladmin£¬ÄÇôÕâÖÖ·½·¨¾ÍÊÇÎÞЧµÄ£¬¶øÇÒmysqladminÎÞ·¨°ÑÃÜÂëÇå¿Õ¡£
ÏÂÃæµÄ·½·¨¶¼ÔÚmysqlÌáʾ·ûÏÂʹÓã¬ÇÒ±ØÐëÓÐmysqlµÄrootȨÏÞ£º
·½·¨Èý
mysql> INSERT INTO mysql.user (Host,User,Password) VALUES (¡¯%¡¯,¡¯system¡¯, PASSWORD(¡¯manager¡¯));
mysql> FLUSH PRIVILEGES
¡¡¡¡È·ÇеØ˵ÕâÊÇÔÚÔö¼ÓÒ»¸öÓû§£¬Óû§ÃûΪsystem£¬ÃÜÂëΪmanager¡£×¢ÒâҪʹÓÃPASSWORDº¯Êý£¬È»ºó»¹ÒªÊ¹ÓÃFLUSH PRIVILEGESÀ´Ö´ÐÐÈ·ÈÏ¡£
·½·¨ËÄ
ºÍ·½·¨ÈýÒ»Ñù£¬Ö»ÊÇʹÓÃÁËREPLACEÓï¾ä
mysql> REPLACE INTO mysql.user (Host,User,Password)
VALUES(¡¯%¡¯,¡¯system¡¯,PASSWORD(¡¯manager¡¯));
mysql> FLUSH PRIVILEGES
·½·¨Îå
ʹÓÃSET PASSWORDÓï¾ä
mysql> SET PASSWORD FOR system@"%" = PASSWORD(¡¯manager¡¯);
ÄãÒ²±ØÐëʹÓÃPASSWORD()º¯Êý£¬µ«ÊDz»ÐèҪʹÓÃFLUSH PRIVILEGESÀ´Ö´ÐÐÈ·ÈÏ¡£
·½·¨Áù
ʹÓÃGRANT ... IDENTIFIED BYÓï¾ä£¬À´½øÐÐÊÚȨ¡£
mysql> GRANT USAGE ON *.* TO system@"%" IDENTIFIED BY ¡¯manager¡¯;
ÕâÀïPASSWORD()º¯ÊýÊDz»±ØÒªµÄ£¬Ò²²»ÐèҪʹÓÃFLUSH PRIVILEGESÀ´Ö´ÐÐÈ·ÈÏ¡£
×¢£ºPASSWORD()º¯Êý×÷ÓÃÊÇΪ¿ÚÁî×Ö¼ÓÃÜ£¬ÔÚ³ÌÐòÖÐMySql×Ô¶¯½âÊÍ¡£
¶þ¡¢MySqlÖзÃÎÊÏÞÖƵÄÉèÖ÷½·¨
ÎÒÃDzÉÓÃÁ½ÖÖ·½·¨À´ÉèÖÃÓû§¡£
¡¡¡¡½øÈëµ½MysqlÖ´ÐÐĿ¼Ï£¨Í¨³£ÊÇc:mysqlin£©¡£ÊäÈëmysqld-shareware.exe£¬ÊäÈëmysql --user=root mysql ,²»È»²»ÄÜÌí¼ÓÐÂÓû§¡£½øÈëµ½mysql>Ìáʾ·ûϽøÐвÙ×÷¡£
¼ÙÉèÎÒÃÇÒª½¨Á¢Ò»¸ö³¬¼¶Óû§£¬Óû§ÃûΪsystem£¬Óû§¿ÚÁîΪmanager¡£
·½·¨Ò»
ÓÃGrant ÃüÁîÊÚȨ£¬ÊäÈëµÄ´úÂëÈçÏ£º
mysql>GRANT ALL PRIVILEGES ON *.* TO system@localhost IDENTIFIED BY ¡¯manager¡¯ WITH GRANT OPTION;
Ó¦ÏÔʾ:Query OK, 0 rows affected (0.38 sec)
·½·¨¶þ
¶ÔÓû§µÄÿһÏîȨÏÞ½øÐÐÉèÖãº
mysql>INSERT INTO user VALUES(¡¯localhost¡¯,¡¯system¡¯,PASSWORD(¡¯manager¡¯), ¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯,¡¯Y¡¯);
¶ÔÓÚ3.22.34°æ±¾µÄMySQL,ÕâÀï¹²14¸ö"Y",ÆäÏàÓ¦µÄȨÏÞÈçÏÂ(°´×Ö¶Î˳ÐòÅÅÁÐ):
¡¡
ȨÏÞ ±íÁÐÃû³Æ ÏàÓ¦½âÊÍ Ê¹Ó÷¶Î§
select Select_priv Ö»ÓÐÔÚÕæÕý´ÓÒ»¸ö±íÖмìË÷ʱ²ÅÐèÒªselectȨÏÞ ±í
insert Insert_priv ÔÊÐíÄú°ÑÐÂÐвåÈëµ½Ò»¸ö´æÔڵıíÖÐ ±í
update Update_priv ÔÊÐíÄãÓÃÐÂÖµ¸üÐÂÏÖ´æ±íÖÐÐеÄÁÐ ±í
delete Delete_priv ÔÊÐíÄãɾ³ýÂú×ãÌõ¼þµÄÐÐ ±í
create Create_priv ÔÊÐíÄã´´½¨ÐµÄÊý¾Ý¿âºÍ±í Êý¾Ý¿â¡¢±í»òË÷Òý
drop Drop_priv Å×Æú(ɾ³ý)ÏÖ´æµÄÊý¾Ý¿âºÍ±í Êý¾Ý¿â»ò±í
reload Reload_priv ÔÊÐíÄú¸æËß·þÎñÆ÷ÔÙ¶ÁÈëÊÚȨ±í ·þÎñÆ÷¹ÜÀí
shutdown Shutdown_priv ¿ÉÄܱ»ÀÄÓÃ(ͨ¹ýÖÕÖ¹·þÎñÆ÷¾Ü¾øΪÆäËûÓû§·þÎñ) ·þÎñÆ÷¹ÜÀí
process Process_priv ÔÊÐíÄú²ì¿´µ±Ç°Ö´ÐеIJéѯµÄÆÕͨÎı¾,°üÀ¨É趨»ò¸Ä±ä¿ÚÁî²éѯ ·þÎñÆ÷¹ÜÀí
file File_priv ȨÏÞ¿ÉÒÔ±»ÀÄÓÃÔÚ·þÎñÆ÷É϶ÁÈ¡ÈκοɶÁµÄÎļþµ½Êý¾Ý¿â±í ·þÎñÆ÷ÉϵÄÎļþ´æÈ¡
grant Grant_priv ÔÊÐíÄã°ÑÄã×Ô¼ºÓµÓеÄÄÇЩȨÏÞÊÚ¸øÆäËûµÄÓû§ Êý¾Ý¿â»ò±í
references References_priv ÔÊÐíÄã´ò¿ªºÍ¹Ø±Õ¼Ç¼Îļþ Êý¾Ý¿â»ò±í
index Index_priv ÔÊÐíÄã´´½¨»òÅ×Æú(ɾ³ý)Ë÷Òý ±í
alter Alter_priv ÔÊÐíÄú¸Ä±ä±í¸ñ,¿ÉÒÔÓÃÓÚͨ¹ýÖØÐÂÃüÃû±íÀ´ÍƷȨÏÞϵͳ ±í
Èç¹û´´½¨Óû§Ê±Ö»ÓÐselect¡¢insert¡¢updateºÍdeleteȨÏÞ,ÔòÔÊÐíÓû§Ö»ÄÜÔÚÒ»¸öÊý¾Ý¿âÏÖÓеıíÉÏʵʩ²Ù×÷.
ÏÂÃæ¾Í¿ÉÒÔ´´½¨ÎÒÃÇÒªÓõ½µÄÊý¾Ý¿âÁË,ÎÒÃÇÖ±½ÓÊäÈë. ÀýÈ磺ÎÒÃÇÒª´´½¨Êý¾Ý¿âÃûΪXinXiKu£¬¿ÉÓÃÈçÏ´úÂ룺
mysql>create database XinXiKu;
Ó¦ÏÔʾ:Query OK, 1 row affected (0.00 sec)