詳細(xì)說明mysql客戶端授權(quán)后連接失敗的問題的處理方法
發(fā)表時(shí)間:2023-09-10 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]下面小編就為大家?guī)硪黄昝澜鉀Qmysql客戶端授權(quán)后連接失敗的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧在本地(192.168.1.152)部署好mysql環(huán)境,授權(quán)遠(yuǎn)程客戶機(jī)192.168.1.%連接本機(jī)的mysql,在iptables防火墻也已開通33...
下面小編就為大家?guī)硪黄昝澜鉀Q
mysql客戶端授權(quán)后連接失敗的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
在本地(192.168.1.152)部署好mysql環(huán)境,授權(quán)遠(yuǎn)程客戶機(jī)192.168.1.%連接本機(jī)的mysql,在iptables防火墻也已開通3306端口。
如下:
mysql>
select host,user,passw
ord
from mysql.user;
+--------------+-----------------+---------------------------------------------------------+
host user password
+--------------+-----------------+----------------------------------------------------------+
localhost root
fdm1 root
127.0.0.1 root
localhost
fdm1
192.168.1.% db_hqsb *DFC9DC16B13651A95ECEC3A26E07D244431B55C9
192.168.1.% db_ro_hqsb *2C0B0DD50595BB40879110437BEEF026D019DFB7
192.168.1.% db_jkhwuser *2C0B0DD50595BB40879110437BEEF026D019DFB7
192.168.1.25 slave *EE52B8EACB3CCD13624273AD6B5CDA52B9B53EB7
192.168.1.% tech_db_user *6053E57C7B61043DC2C6B4E3291D5F61CCC23F5C
192.168.1.% game_db_user *05EA4D71C9A1273ECF3E24E6323F7175AE45C366
localhost zabbix *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
+---------------+---------------+------------------------------------------------------------+
問題:
在客戶機(jī)(比如192.168.1.20)上遠(yuǎn)程連接上面192.168.1.152機(jī)器的mysql,連接失!
[root@huanqiu ~]# mysql -udb_ro_hqsb -h 192.168.1.152 -pmhxzkhl0802xqsjdb
ERROR 1130 (HY000): Host '192.168.1.20' is not allowed to connect to this MySQL server
解決:
是由于192.168.1.152的mysql里“host為localhost,user和password為空”這條語句導(dǎo)致的,刪除這條即可解決問題!
mysql>
delete
from mysql.user where host="localhost" and user="";
Query OK, 1 row affected (0.00 sec)
mysql>
flush
privileges;
Query OK, 0 rows affected (0.00 sec)
這樣,授權(quán)連接的客戶機(jī)就能成功連接了!
[root@huanqiu ~]# mysql -uxqsj_db_ro_user -h 192.168.1.152 -pmhxzkhl0802xqsjdb
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
以上就是詳解mysql客戶端授權(quán)后連接失敗的問題的解決辦法的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門到精通的SQL知識。