Forums

connecting to my mysql database

I am trying to access my mysql database outside on my local terminal. I have been successful in accessing my webapp, but not the remote mysql database through ssh -v -L 3333: <user_name>.mysql.pythonanywhere-services.com:3306 <user_name>.mysql.pythonanywhere-services.com

The script just times out when making the request ssh: connect to host <database_name>.mysql.pythonanywhere-services.com port 22: Operation timed out

Also tried

    with sshtunnel.SSHTunnelForwarder(
    ('ssh.pythonanywhere.com'),
    ssh_username='user_name', ssh_password='password',
    remote_bind_address=('user_name.mysql.pythonanywhere-services.com', 3333)
) as tunnel:
    connection = mysql.connector.connect(
        user='user_name', password='f'password',
        host='127.0.0.1', port=tunnel.local_bind_port,
        database='ghidalgo$Newsletter',
    )

Without much success. I have read thes a couple of times and still no idea what is going on can anyone help? - https://help.pythonanywhere.com/pages/SSHAccess/ https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/

Your first tunnel command is incorrect, the second <user_name>.mysql.pythonanywhere-services.com needs to be ghidalgo@ssh.pythonanywhere.com

I don't think the second one is actually the code you're running, because that code would most likely fail with a syntax error (the 'f'password' introduces unbalanced single quotes). Show us the code that you're actually running and describe what happens when you run it.

I have ran

ssh -v -L 3333:ghidalgo.mysql.pythonanywhere-services.com:3306 ghidalgo.mysql.pythonanywhere-services.com

And it times out here

OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
debug1: Reading configuration data /Users/gabrielhidalgo/.ssh/config
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug1: Connecting to ghidalgo.mysql.pythonanywhere-services.com [34.193.52.63] port 22.
debug1: connect to address 34.193.52.63 port 22: Operation timed out
ssh: connect to host ghidalgo.mysql.pythonanywhere-services.com port 22: Operation timed out

See my previous post. You're not connecting to the ssh server to create the tunnel. Both of your addresses are to your mysql server where the second one needs to be to the ssh server.