MySQL Forums
Forum List  »  General

Error 1045 (28000) when using ssh tunnels
Posted by: Carol Szabo
Date: October 15, 2010 10:38AM

Hi I just lost about half a day on this so I thought I should publish the results so that hopefully someone else does not run into the same thing.
I have a MySQL server that is out on the open internet and I need to access it from behind the firewall and HTTP proxy that my company uses to protect the intranet.
On an Ubuntu server, I use ssh and corkscrew to tunnel the connection through the http proxy. The idea is that to the applications on the intranet box it looks like the server is local on port 3309, to the server it looks like someone on the local machine is connecting to port 3306.
I also have a test server on the box I am connecting from that is configured as default, and has of course different passwords then the production server on the internet. So if I connect to port 3306 I am connecting to the test server if I use port 3309 I connect to the production server.
All good and cool right? No.
From Java and when connecting remotely from yet a 3rd Windows box via Putty and MySQL Workbench all went as planned, but when using mysql -u root -P 3309 -pproduction I got Access denied Error 1045 (28000). Same error when trying the connection from python via MySQLDb.
What scratched my head tried all tricks published for this error, nothing worked until this: mysql -u root -P 3309 --protocol=tcp.
And for python nothing worked until I changed the hostname from localhost to 127.0.0.1
The reason is that mysql and the mysql C API ignore the port setting if the hostname is 'localhost' and they use a pipe(unix socket) defined in /etc/my.cnf by default no matter what parameters you pass, so I was ending up connecting to the local mysql for which the root user had a different password.
If you do not have a local instance of mysql or if the instance is not running you get a better error message that says the connection to the unix socket failed, which leads you to the right path.

Options: ReplyQuote


Subject
Written By
Posted
Error 1045 (28000) when using ssh tunnels
October 15, 2010 10:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.