第ä¸ä¸æ¹æ³ï¼æ¯è¾è¯¦ç»
以ä¸çæç« ä¸»è¦ä»ç»çæ¯MySQL æ°æ®åºå¼å¯è¿ç¨è¿æ¥çæ¶æºæä½æµç¨ï¼å
¶å®å¼å¯MySQL
æ°æ®åºè¿ç¨è¿æ¥çå®é
æä½æ¥éª¤å¹¶ä¸é¾ï¼ç¥è¯æ¹æ³å¯¹éèå·²ï¼ä»å¤©æ们è¦å大家æè¿°çæ¯MySQL æ°æ®åºå¼å¯è¿ç¨è¿æ¥çæ¶æºæä½æµç¨ã
1ãd:\MySQL\bin\>MySQL -h localhost -u root
è¿æ ·åºè¯¥å¯ä»¥è¿å
¥MySQLæå¡å¨
å¤å¶ä»£ç
代ç å¦ä¸:
MySQL>update user set host = '%' where
user = 'root';
MySQL>select host, user from user;
2ãMySQL>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY
'mypassword' WITH GRANT OPTION
äºä»»ä½ä¸»æºè®¿é®æ°æ®çæé
3ãMySQL>FLUSH
PRIVILEGES
ä¿®æ¹çæ
4ãMySQL>EXIT
éåºMySQLæå¡å¨
è¿æ ·å°±å¯ä»¥å¨å
¶å®ä»»ä½ç主æºä¸ä»¥root身份ç»å½å¦ï¼
以ä¸çç¸å
³å
容就æ¯å¯¹MySQL æ°æ®åºå¼å¯è¿ç¨è¿æ¥çä»ç»ï¼æä½ è½æææ¶è·ã
第äºç§æ¹æ³:
1ãå¨æ§å¶å°æ§è¡ mysql -u root -p
mysqlï¼ç³»ç»æ示è¾å
¥æ°æ®åºrootç¨æ·çå¯ç ï¼è¾å
¥å®æåå³è¿å
¥mysqlæ§å¶å°ï¼è¿ä¸ªå½ä»¤ç第ä¸ä¸ªmysqlæ¯æ§è¡å½ä»¤ï¼ç¬¬äºä¸ªmysqlæ¯ç³»ç»æ°æ®å称ï¼ä¸ä¸æ ·çã
2ãå¨mysqlæ§å¶å°æ§è¡ GRANT ALL PRIVILEGES ON *.* TO âroot'@'%' IDENTIFIED BY
âMyPassword' WITH GRANT OPTION;
3ãå¨mysqlæ§å¶å°æ§è¡å½ä»¤ä¸ç âroot'@'%' å¯ä»¥è¿æ ·ç解:
rootæ¯ç¨æ·åï¼%æ¯ä¸»æºåæIPå°åï¼è¿éç%代表任æ主æºæIPå°åï¼ä½ ä¹å¯æ¿æ¢æä»»æå
¶å®ç¨æ·åææå®å¯ä¸çIPå°åï¼'MyPassword'æ¯ç»ææç¨æ·æå®çç»å½æ°æ®åºçå¯ç ï¼å¦å¤éè¦è¯´æä¸ç¹çæ¯æè¿éçé½æ¯æææææéï¼å¯ä»¥æå®é¨åæéï¼GRANTå
·ä½æä½è¯¦æ
è§ï¼
http://dev.mysql.com/doc/refman/5.1/en/grant.html 4ãä¸æ¾å¿çè¯å¯ä»¥å¨mysqlæ§å¶å°æ§è¡ select host, user from user; æ£æ¥ä¸ä¸ç¨æ·è¡¨éçå
容