我在我的机器上设置了MySQL端口转发:
I have set up MySQL port forwarding in my machine as:
ssh -f -N -L :9906:localhost:3306 《ssh login》
现在,如果我尝试从我的localhost连接到MySQL:
Now, if I try to connect to MySQL from my localhost as:
mysql -u《user》 -p《password》 -P9906 -h127.0.0.1 《schema》
工作正常。 但是,如果我在本地取出 `-` h参数,即,如果我从localhost连接到MySQL,如下所示:
It works fine. But, if I take out the `-`h parameter in my local, i.e, if I connect to MySQL as below from localhost:
mysql -u《user》 -p《password》 -P9906 《schema》
我收到以下错误:
I get the following error:
>
>
> 错误1045(28000):对用户'''localhost'的访问被拒绝。 (使用密码:是)
》 ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: YES)
为什么会出现这种情况?
Why this behaviour?
我曾尝试为localhost和127.0.0.1设置端口转发,但错误仍然存在。
I have tried to set the port forwarding for both localhost as well as 127.0.0.1, but the error still remains.
此外,在服务器上,已为localhost和127.0.0.1提供了用户权限。
Also, on the server, have given privilege to the user for both localhost as well as 127.0.0.1.