Linux下設定MySQL資料庫允許遠端連線

來源:互聯網
上載者:User

Linux下設定MySQL資料庫允許遠端連線

如果通過用戶端工具串連Linux下的MySQL資料庫出現以下錯誤

Host '192.168.1.3' is not allowed to connect to this MySQL server 的解決方案:

1,在Linux本機下訪問mysql資料庫

[root@mail ~]# mysql -u root -p root

若出現Can't connect to local MySQL server through socket 的提示的解決方案

修改/etc/my.cnf
[mysqld]
datadir=/database/mysql
socket=/database/mysql/mysql.sock
[client]
socket=/database/mysql/mysql.sock

之所以要修改client這段內容是因為如果不時明確指出mysql用戶端程式還是會連到/var/lib/mysql/mysql.sock這個socket上面去,此時雖然資料庫已經正常啟動,www.bkjia.com使用mysql串連資料庫是還是會報找不到/var/lib/mysql/mysql.sock的錯誤
2,串連上資料庫後執行

(1) 改表法。更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"

mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user;


(2). 授權法
grant all on *.* to 'root'@'10.1.1.201' identified by 'root';

則ip為10.1.1.201的使用者可以遠端連線資料庫了。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.