Host 'xxx' is not allowed to connect to this MySQL server.
今天在伺服器安裝了mysql,準備用mysqlguitools遠端登入的時候出錯,提示:Host ‘xxx’ is not allowed to connect to this MySQL server。網上找了一些資料,是mysql未開啟mysql遠端訪問許可權導致。
記錄解決方案供以後參考。:
1.登入到mysql: mysql -uroot -ppwd
2.檢視user表:
mysql> use mysql
Database changed
mysql> select host,user,password from user;
±-----±-----±------------------------------------------+
| host | user | password |
±-----±-----±------------------------------------------+
| localhost | root | *826960FA9CC8A87953B3156951F3634A80BF9853 |
±-----±-----±------------------------------------------+
1 row in set (0.00 sec)
表中host、user欄位標識了可以訪問資料庫的主機和使用者。例如上面的資料就表示只能本地主機通過root使用者訪問。原來如此,難怪遠端連線死活連不上。
為了讓資料庫支援遠端主機訪問,有兩種方法可以開啟遠端訪問功能。
第一種(改表法):
修改host欄位的值,將localhost修改成需要遠端連線資料庫的ip地址。或者直接修改成%。修改成%表示,所有主機都可以通過root使用者訪問資料庫。為了方便,我直接修改成%。命令:mysql> update user set host = ‘%’ where user = ‘root’;
再次檢視user表
±-----±-----±------------------------------------------+
| host | user | password |
±-----±-----±------------------------------------------+
| % | root | *826960FA9CC8A87953B3156951F3634A80BF9853 |
±-----±-----±------------------------------------------+
1 row in set (0.00 sec)
修改成功,輸入命令mysql> FLUSH PRIVILEGES; 回車使剛才的修改生效,再次遠端連線資料庫成功。
第二種(授權法):
例如,你想root使用mypassword從任何主機連線到mysql伺服器的話。
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;
如果你想允許使用者myuser從ip為192.168.1.3的主機連線到mysql伺服器,並使用mypassword作為密碼
GRANT ALL PRIVILEGES ON . TO ‘root’@‘192.168.1.3’ IDENTIFIED BY
‘mypassword’ WITH GRANT OPTION;
輸入命令mysql> FLUSH PRIVILEGES; 回車使剛才的修改生效,再次遠端連線資料庫成功。bingo.
別忘記最後的FLUSH PRIVILEGES; 重新整理先前的修改。
本文轉載:https://www.cnblogs.com/vathena/p/4012399.html
相關文章
- Host 'xxx' is not allowed to connect to this MySQL server 解決方法MySqlServer
- 解決MySql報錯:1130 - Host ‘xxx‘ is not allowed to connect to this MySQL server的方法MySqlServer
- Host 'localhost' is not allowed to connect to this MySQL serverlocalhostMySqlServer
- “Host ‘xxxx‘ is not allowed to connect to this MySQL server“MySqlServer
- MySQL-1130-host ... is not allowed to connect to this MySql serverMySqlServer
- Navicat連線centos裡mysql報錯Host is not allowed to connect to this MySQL serverCentOSMySqlServer
- 虛擬機器NAT模式下連線mysql報錯:Host '192.168.30.1' is not allowed to connect to this MySQL server虛擬機模式MySqlServer
- navicat無法連線遠端的mysql--Host ‘xx.xx.xx.xx‘ is not allowed to connect to this MySQL server“MySqlServer
- 上手MySQL之解決問題:not allowed to connect to this MySQL serverMySqlServer
- 連線mysql時提示is not allowed to connect不允許連線MySql
- could not connect to redis Instance at xxx.xxx.xxx.xxx:6379Redis
- 關於對連線資料庫時出現1130-host “**” is not allowed to connect to this MySql/mariadb server 的錯誤解決方法資料庫MySqlServer
- ssh: connect to host localhost port 22: Connection refusedlocalhost
- unable to access ‘https://gitee.com/XXX/XXX.git/‘: Failed to connect to 127.0.0.1 portHTTPGiteeAI127.0.0.1
- 坑:ssh: connect to host github.com port 22: Connection refusedGithub
- 異常解決——GitLab : ssh: connect to host port 22: Connection refusedGitlab
- 解決 ssh connect to host github.com port 22 Connection timed outGithub
- 【問題解決】java.sql.SQLException: null, message from server: “Host ‘xxx.xx.xx.xxx‘ is blocked because ofJavaSQLExceptionNullServerBloC
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- 關於出現requests.exceptions.SSLError: HTTPSConnectionPool(host=‘XXX‘, port=443)問題ExceptionErrorHTTP
- MySQL報錯:Packets larger than max_allowed_packet are not allMySql
- Mysql資料庫的max_allowed_packet設定方法MySql資料庫
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- nodejs 連結mysql出現 connect ECONNREFUSED ::1:3306NodeJSMySql
- MySQL:connect_timeout引數簡單記錄MySql
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- 技術分享 | MySQL:max_allowed_packet 影響了什麼?MySql
- C++ vector<std::tuple<XXX, XXX, XXX>>C++
- Serialization of 'Closure' is not allowed
- Mysql host is blocked because of many connection errors;unblock解決方法MySqlBloCError
- proxy_set _header Host $host;Header
- Mysql異常刨析:Could not commit JDBC transaction;No operations allowed after statement closedMySqlMITJDBC
- MySQL Case-max_allowed_packet過小是否會擷取sql文字MySql
- 116 svn連線提示can't connect to the host'***':由於目標機積極拒絕,無法連線。
- ubuntu ssh: connect to host ** port 22: Connection refused ssh登入遠端伺服器時提示Permission denied (publickey,password)Ubuntu伺服器
- 連線mysql報錯lost connect to sever during query解決MySql
- max_allowed_packet引起MySQL遷移丟失資料的問題MySql
- net core 的Generic Host 之Generic Host BuilderUI