我已经在两台服务器A和B之间建立了 SSH 隧道。B有 MySQL 服务器,这有效:
mysql -h localhost -P 3306 -u user -p
虽然这不是:
mysql -h 127.0.0.1 -P 3306 -u user -p
虽然 my.cnf 有以下几行:
bind-address = 127.0.0.1
# Next addr differs slightly, but anyway
bind-address = 99.99.99.99
现在关于隧道。它连接以下内容:(A) localhost(9989) -> (B) localhost(3306)
但是当(在A上,端口转发)我做
mysql -v -h 127.0.0.1 -P 9989 -u user userdb -p
我明白了ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
当我这样做时
mysql -v -h localhost -P 9989 -u user userdb -p
我明白了ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
可能是什么原因?我究竟做错了什么?