I have set up MySQL port forwarding in my machine as:
ssh -f -N -L :9906:localhost:3306 <ssh login>
Now, if I try to connect to MySQL from my localhost as:
mysql -u<user> -p<password> -P9906 -h127.0.0.1 <schema>
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:
ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: YES)
Why this behaviour?
I have tried to set the port forwarding for both localhost as well as 127.0.0.1, but the error still remains.
Also, on the server, have given privilege to the user for both localhost as well as 127.0.0.1.