0
votes

I am trying to connect to VPS mysql database from my PC. I use sqlalchemy framework, but I need establish SSH tunnel before connection.

Usual way, when web app run on VPS:

create_engine('mysql://user:pswd@localhost/dbname')

How can I connect to this database from another PC. Assume there are connections credentials: IP, username, password

1
What happens when you replace localhost with the IP address of the database server? - Selcuk
When I pass IP with SSH port 22: sqlalchemy.exc.OperationalError: (OperationalError) (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0") None None - Šimon Kostolný
And with mysql port 3306: sqlalchemy.exc.OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111)") None None - Šimon Kostolný

1 Answers

1
votes

Your MySQL server is listening to local connections only. To make it listen to outside connections:

  1. Edit the /etc/mysl/my.cnf file
  2. Comment out the line bind-address = 127.0.0.1
  3. Restart mysqld