1、打開mysql.exe(MySQL Command Line Client),輸入密碼
2、輸入:use mysql;
3、查詢host輸入: select user,host from user;
4、創建host(如果有"%"這個host值,則跳過這一步)
如果沒有"%"這個host值,就執行下面這兩句:
mysql> update user set host='%' where user='root';
mysql> flush privileges;
5、授權用戶
(1)任意主機以用戶root和密碼pwd連接到mysql服務器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pwd' WITH GRANT OPTION;
mysql> flush privileges;
(2)指定IP為(如192.168.1.100)的主機以用戶tuser和密碼tpwd連接到mysql服務器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'tuser'@'192.168.1.100' IDENTIFIED BY 'tpwd' WITH GRANT OPTION;
mysql> flush privileges;