sqlalchemy connect to VPS database

2019-09-10 08:09发布

问题:

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:

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