PyMySQL can't connect to MySQL on localhost

后端 未结 8 1854
囚心锁ツ
囚心锁ツ 2020-11-28 08:26

I\'m trying to connect to MySQL on localhost using PyMySQL:

import pymysql
conn = pymysql.connect(db=\'base\', user=\'         


        
8条回答
  •  自闭症患者
    2020-11-28 08:43

    I met the same question and my solution is as follows:

    1. Run ssh -fN -L 3307:mysql_host:3306 ssh_user@ssh_host in my terminal.
    2. Then input your ssh password
    3. conn = pymysql.connect(db='base', user='root', passwd='pwd', host='localhost')

    This error occurs because database does not support link directly.

提交回复
热议问题