Mysql – Can’t Connect to MySQL database through PuTTY


I have a database that runs on, and am trying to connect Tableau to it, and need to set up an SSH Tunnel in order to do so.

The directions on pythonanywhere's website mention PuTTY, and many people on Tableau forums also use it, so this is what I'm going with. I've been trying for about 2 weeks to get this working, but no luck.

So here's what happens:

1). I enter as the host connection on the main page:
enter image description here

2). I then go to SSH –> Tunnels, and enter the following information:
enter image description here

The information in the Destination field has the form

Then I hit Open, and am prompted for my sign in credentials to Python Anywhere:

enter image description here

Then I go to Tableau and enter the following information:

enter image description here

In the password field I type in my database password.

The message that always comes up is:

[MySQL][ODBC 8.0(w) Driver]Access denied for user 'myusername'@'localhost' (using password: YES)
Invalid username or password.

Now obviously, there's a natural response to this: double check my password.

For now just take my word for it that I've double checked this several times and it is correct.

I've tried to find help on PythonAnywhere's forums, and Tableau's forums, but no solutions have been found.


I've tried switching out the port with localhost, but this did not work.

I have connected to my database externally in a Jupyter Notebook using this same information, so I have some confirmation that this info has been used successfully.

I've tried connecting to MySQL Workbench using the same info and I get the same error message, which makes me think there's something about my database configuration which is not working, but I have no idea where to look.


In my PuTTY Bash terminal the command telnet 3306 returns the message:

telnet: Unable to connect to remote host: Connection refused

In my DOS terminal I get the following:

enter image description here

In my git BASH terminal I type in netstat -an|grep 3306 and get:

enter image description here


I was on codementor trying to get this resolved, and we had the following issue:

after signing in throuhg PuTTY, I entered the following command:

mysql -h -u jonathanbechtel -p

Which returned the following error message:

ERROR 2003 (HY000): Can't connect to MySQL server on '' (111)

We also tried switching out with localhost and got a different error message:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

To be honest I don't understand the significance of this, but was told by him that this is unusual and might signal some security settings on my account with PythonAnywhere. I started this forum message on their forums to try and troubleshoot it.

Best Answer

If you are connecting on "localhost", then GRANT ... TO user@localhost ... applies. "" may be a synonym for "localhost".

If you are connecting via TCP/IP, then GRANT ... TO user@'' ... applies. (Replace with suitable IP or hostname or wildcard.)

It is OK to have both GRANTs in order to allow access either way.