1.修改配置檔案
sudo vim /etc/mysql/my.cnf
把bind-address參數的值改成你的内/外網IP或0.0.0.0,或者直接注釋掉這行.
2.登入資料庫
mysql -u root -p
輸入密碼
mysql> use mysql;
3.查詢host
mysql> select user,host from user;
4.建立host
如果沒有"%"這個host值,就執行下面這兩句:
mysql> update user set host='%' where user='root';
mysql> flush privileges;
5.授權使用者
任意主機以使用者root和密碼mypwd連接配接到mysql伺服器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
IP為192.168.1.102的主機以使用者myuser和密碼mypwd連接配接到mysql伺服器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.102' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
未來星開發團隊--狒狒
QQ:9715234