mysqldbcompare访问被拒绝,但mysql命令有效 [英] mysqldbcompare access denied but mysql command works
问题描述
我正在尝试使用mysqldbcompare
工具,但出现连接错误:
I'm trying to use the mysqldbcompare
tool but getting a connection error:
$ mysqldbcompare --server1=client --skip-data-check db1:db2
# server1 on <ip>: ...
ERROR: Access denied for user 'root'@'<ip>' (using password: YES)
我可以使用mysql
并很好地连接.我使用mysql_config_editor --host=<ip> --user=root --port=3306 --password
设置了凭据,并在没有传递所有args(mysql -u root -p -h <ip> -P 3306
)的情况下使用mysql
命令进行了测试.
I can use mysql
and connect just fine, though. I setup my creds using mysql_config_editor --host=<ip> --user=root --port=3306 --password
and tested with the mysql
command with and without passing all the args (mysql -u root -p -h <ip> -P 3306
).
我已经检查了服务器的绑定地址,并查看了服务器错误日志,但它只是重申了连接被拒绝的消息.我已经在网上搜索(并在SO上搜索),但找不到任何东西.
I've checked the bind address of the server and looked in the server error logs but it just reiterates a connection refused message. I've searched online (and on SO) but haven't been able to find anything.
感谢您的帮助.
推荐答案
当您遇到访问被拒绝的错误时,它表示 TCP连接已建立,但是您提供的密码错误for 'User'@'Host'
(用户-主机对是用于MySQL身份验证的真实帐户,而不是单个用户名).
When you encountered an access denied error it means the TCP connection has been established, but the password you provided is wrong for'User'@'Host'
(a User-Host pair is a real account for MySQL authentication, not a single username).
假定MySQL服务器在172.0.0.8
上运行,并且您的本地地址为172.0.0.5
.
Assume that MySQL server runs on 172.0.0.8
and your local address is 172.0.0.5
.
- 通过以下方式查看
mysql.user
:SELECT * FROM mysql.user\G;
.如果找不到以下两个用户-主机对之一:'root'@'172.0.0.5'
和'root'@'%'
,则意味着没有这样的帐户.所以你失败了. - 还要从上面的输出中检查已存在的User-Host对的密码.
- 现在,连接很好,该帐户存在,密码正确,出现这种错误的唯一机会是:mysqldbcompare没有使用您提供的参数!
- 尝试其他解决方法,例如:
mysqldbcompare --server1=root:password@172.0.0.8:3306 --skip-data-check db1:db2
- Take a look at
mysql.user
by:SELECT * FROM mysql.user\G;
. If you can't find either of these two User-Host pairs:'root'@'172.0.0.5'
and'root'@'%'
, it means there is no such account. So you failed. - Also check the password of the existed User-Host pair from the output above.
- Now, the connection is fine, the account exists, the password is right, the only chance for such an error is: mysqldbcompare didn't use the arguments you provided!
- Try other workaround like:
mysqldbcompare --server1=root:password@172.0.0.8:3306 --skip-data-check db1:db2
逐步检查所有这些内容,您会弄清楚.
Check all these stuff step by step, and you will figure it out.
这篇关于mysqldbcompare访问被拒绝,但mysql命令有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!