在linux系統下遠端訪問mysql資料庫

2021-08-21 18:23:51 字數 1344 閱讀 5643

第一:更改 「mysql」 資料庫裡的 「user」 表裡的 「host」 項,從」localhost」改稱'%'。 

或者新加條記錄,「host」 項為要訪問的ip位址,並授權。重啟mysql服務。

第二:在系統防火牆新增例外埠:3306,並允許例外。

error 1130: host '192.168.1.3' is not allowed to connect to this mysql server

的解決方法:

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

1.mysql -u root -pvmware

mysql>use mysql;

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

mysql>select host, user from user;

2. 授權法。例如,你想myuser使用mypassword從任何主機連線到mysql伺服器的話。

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

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

grant all privileges on *.* to 'myuser'@'192.168.1.3' identified by 'mypassword' with grant option;

3.在window自帶的防火牆裡的例外新增3306埠

總結:

mysql -u root -p

mysql>use mysql;

mysql>select 'host' from user where user='root';

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

mysql>flush privileges;

mysql>select 'host' from user where user='root';

第一句是以許可權使用者root登入

第二句:選擇mysql庫

第三句:檢視mysql庫中的user表的host值(即可進行連線訪問的主機/ip名稱)

第六句:再重新檢視user表時,有修改。。

重起mysql服務即可完成。

windows下遠端訪問Linux系統中mysql

1,查詢mysql資料庫是否允許遠端ip訪問,命令如下 sql語句 查詢結果為127.0.0.1或者localhost或者當前伺服器網域名稱,則表示不允許遠端連線。更改許可權 開啟遠端訪問 sql 表示root使用者下的所有資料庫所有表允許遠端訪問 mysql grant 許可權1,許可權2,許可權...

linux下遠端訪問Mysql

mysql的root賬戶,我在連線時通常用的是localhost或127.0.0.1,公司的測試伺服器上的mysql也是localhost所以我想訪問無法訪問,測試暫停.解決方法如下 1,修改表,登入mysql資料庫,切換到mysql資料庫,使用sql語句檢視 select host,user fr...

Linux下遠端訪問redis

protected mode屬性值為yes 啟動保護模式,保護模式下不支援遠端訪問redis 遠端主機能訪問redis服務的條件 可以用scp命令傳送redis可執行檔案到遠端,eg scp r home ywee bigdatasoftware redis redis 3.2.1 redis bi...