![]() This could be your problem too since the socket methods works just fine but the TCP one does not. I asked why socket worked but not TCP and the answer was that bind-address in /etc/my.cnf was not set correctly. This error occurs because database does not support link directly. conn = nnect(db='base', user='root', passwd='pwd', host='localhost').Run ssh -fN -L 3307:mysql_host:3306 _host in my terminal.I met the same question and my solution is as follows: Additionally, some MySQL connectors will use a socket when connecting to localhost but use TCP/IP when connecting to 127.0.0.1. I solved the issue by replacing localhost with 127.0.0.1 and changing the password to my MYSQL database password as shown below conn = nnect( MySQL considers 127.0.0.0/8 addresses to be different from localhost so when creating users if you specify one you need to connect using that one reference. If it doesn't, I would look for errors in tcp sockets connection and, of course, post it as a bug in pymysql bugtrack. Seems like changing localhost to 127.0.0.1 fixes the error, at least in my configuration. ![]() ![]() If not, you can set the port manually like so: nnect(db='base', user='root', passwd='pwd', host='localhost', port=XXXX) Run mysqladmin variables | grep port and verify that the port is 3306. ![]() Run mysqladmin variables | grep socket to get where the socket is located, and try setting up a connection like so: nnect(db='base', user='root', passwd='pwd', unix_socket="/tmp/mysql.sock")
0 Comments
Leave a Reply. |