Sample Header Ad - 728x90

How I can allow my user to be connected via `localhost` when I ssh tunnel my Db connection?

1 vote
1 answer
45 views
In a server that I do not have admin access I managed to make an ssh tunnel as:
ssh -N -L 33308:127.0.0.1:3306 user@example.com
Then I attempt to connect into mysql via the tunnel:
mysql -u testusr -p -h 127.0.0.1 -P 33308 testdb
By I ended getting the error:
ERROR 1045 (28000): Access denied for user 'testusr'@'127.0.0.1' (using password: YES)
But once I have a shell session upon DB I manage to connect into mysql like this:
mysql -u testusr -p -h localhost testdb
mysql>
But I am unable to connect like this:
mysql -u testusr -p -h 127.0.0.1 testdb
ERROR 1045 (28000): Access denied for user 'testusr'@'127.0.0.1' (using password: YES)
Meaning that testusr is able to be connected via providing localhost as domain upon connection. So how I can setup the tunnel in order to be able to connect as?
mysql -u testusr -p -h localhost -P 33308 testdb
Upon my local machine?
Asked by Dimitrios Desyllas (1301 rep)
Mar 13, 2025, 01:35 PM
Last activity: Mar 13, 2025, 02:26 PM