Remotely connect to MySQL with Python mysql.connector

前端 未结 1 1869
不思量自难忘°
不思量自难忘° 2021-02-11 02:04

The following code (ran from a different machine than the mysql server, within the same LAN), to locally connect to MySQL database using Python3 and mysql.connector works:

相关标签:
1条回答
  • 2021-02-11 02:39

    If you're running PHPMyAdmin on the same server that your mysql daemon is running on, here's what's happening: you have your webserver configured to accept connections from all interfaces, but mysql configured to only accept local connections. Since PHPMyAdmin is colocated wit mysql, it will only be making local connections which is why it works but your code doesn't.

    So, double check that your mysql daemon is configured to listen interfaces. You should have a line something like bind-address=0.0.0.0 in your mysql.cnf file. See this answer for more details.

    0 讨论(0)
提交回复
热议问题