無法從本地連線伺服器的Mysql
阿新 • • 發佈:2019-02-12
Mysql從客戶端連線伺服器連不上的問題
公司要用Mysql做一個測試,開始在自己的本地建一個Mysql資料庫自己本地的程式再連上去,沒有遇到過連線不上的問題。
這次資料庫在伺服器上,從本地客戶端連線就是被拒絕。
報的錯誤為 ERROR 1130: Host ’192.168.5.3’ is not allowed to connect to this MySQL server www.2cto.com 查過資料後發現這個問題,一般都會遇到,Mysql資料庫跟其他資料庫不一樣,需要設定許可權可以控制哪臺機器能訪問資料庫,能訪問哪些表。 所以就要登上伺服器。 C:\Documents and Settings\Administrator>mysql -h localhost -u root -p Enter password: *** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.43-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. www.2cto.com mysql> grant all privileges on *.* to 'root'@'%' identified by '123' with grant -> option; Query OK, 0 rows affected (0.00 sec) 意思就是將伺服器上的所有資源都給root使用者許可權,%代表來自不同的IP 這裡需要注意一下要把密碼也要帶上。通過密碼123登入。 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) 最後要重新整理下許可權。 這樣就從本地192.168.5.3這個IP的客戶端連線到伺服器上了 轉載於:http://www.2cto.com/database/201204/128795.html 感謝kjqin的分享
這次資料庫在伺服器上,從本地客戶端連線就是被拒絕。
報的錯誤為 ERROR 1130: Host ’192.168.5.3’ is not allowed to connect to this MySQL server www.2cto.com 查過資料後發現這個問題,一般都會遇到,Mysql資料庫跟其他資料庫不一樣,需要設定許可權可以控制哪臺機器能訪問資料庫,能訪問哪些表。 所以就要登上伺服器。 C:\Documents and Settings\Administrator>mysql -h localhost -u root -p Enter password: *** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.43-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. www.2cto.com mysql> grant all privileges on *.* to 'root'@'%' identified by '123' with grant -> option; Query OK, 0 rows affected (0.00 sec) 意思就是將伺服器上的所有資源都給root使用者許可權,%代表來自不同的IP 這裡需要注意一下要把密碼也要帶上。通過密碼123登入。 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) 最後要重新整理下許可權。 這樣就從本地192.168.5.3這個IP的客戶端連線到伺服器上了 轉載於:http://www.2cto.com/database/201204/128795.html 感謝kjqin的分享