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;