遠端訪問Mysql的解決方案

2022-09-06 07:24:13 字數 2176 閱讀 2882

在網上有很多關於這個的解決方案,我也採用了

寫的比較詳細的如:

1. 改表法。

可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"

code:mysql -u root -p123

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

2. 授權法

例如,你想kevin使用mypassword從任何主機連線到mysql伺服器的話。

code:grant all privileges on *.* to 'kevin'@'%' identified by 'mypassword' with grant option;

如果你想允許使用者kevin從ip為192.168.101.234的主機連線到mysql伺服器,並使用mypassword作為密碼

code:grant all privileges on *.* to 'kevin'@'192.168.101.234' identified by 'mypassword' with grant option;

3.如果按照上面這樣做還不行(一般好像在windows下那樣就可以了)那就修改下面這個配置檔案吧(我是在linux環境下 大家可以找到自己mysql安裝目錄下的相應配置檔案)

code:vi /etc/mysql/my.cnf

注釋掉code:#bind-address = 127.0.0.1

大功告成!!!

3.重啟mysql

linux環境下:

停止:service mysqld stop

啟動:service mysqld start

ps:linux中遠端訪問如果還不行,檢查防火牆問題,關閉防火牆。service iptables stop

寫的比較詳細的如:

1. 改表法。

可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"

code:mysql -u root -p123

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

2. 授權法

例如,你想kevin使用mypassword從任何主機連線到mysql伺服器的話。

code:grant all privileges on *.* to 'kevin'@'%' identified by 'mypassword' with grant option;

如果你想允許使用者kevin從ip為192.168.101.234的主機連線到mysql伺服器,並使用mypassword作為密碼

code:grant all privileges on *.* to 'kevin'@'192.168.101.234' identified by 'mypassword' with grant option;

3.如果按照上面這樣做還不行(一般好像在windows下那樣就可以了)那就修改下面這個配置檔案吧(我是在linux環境下 大家可以找到自己mysql安裝目錄下的相應配置檔案)

code:vi /etc/mysql/my.cnf

注釋掉code:#bind-address = 127.0.0.1

大功告成!!!

3.重啟mysql

linux環境下:

停止:service mysqld stop

啟動:service mysqld start

ps:linux中遠端訪問如果還不行,檢查防火牆問題,關閉防火牆。service iptables stop

無法遠端訪問Mysql的解決方案

1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 mysql 資料庫裡的 user 表裡的 host 項,從 localhost 改稱 code mysql u root p123 mysql use mysql...

無法遠端訪問Mysql的解決方案

在網上有很多關於這個的解決方案,我也採用了 寫的比較詳細的如 1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 mysql 資料庫裡的 user 表裡的 host 項,從 localhost 改稱 code my...

無法遠端訪問Mysql的解決方案

在網上有很多關於這個的解決方案,我也採用了 寫的比較詳細的如 1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 mysql 資料庫裡的 user 表裡的 host 項,從 localhost 改稱 code my...