Hi all,
I've been beating my head against the wall, reading, querying the internet, trying the 'solutions' I've found out there, but nothing's
helping me with this problem, so now I'm asking here.
I have a client laptop and a server. The server is running mySQL 8. Both systems are running python3. As I alluded to above, I've done all kinds of fiddling with the mySQL users, /etc/my.cnf, etc.
I have two users defined: root, and grunt. I can log into mysql on the server and do stuff - no problem.
From my laptop, I can do 'mysql -h "serverIP" -u 'root or grunt' -p and log into the server with no problem.
However when I try to execute a python3 script with the following code:
I've tried using /var/run/mysqld/mysqld.sock and linking this to /tmp/mysqld.sock as you see in the code above. Nothing
affects the outcome which is the following message:
the first thing I wonder about is the part that says "Can't connect to local MySQl server...." seems to me that it should "REMOTE"
Second thing is...why can't it connect? What's different about my python script connecting and my sitting at the command line and connecting?
Any help would be GREATLY appreciated!
keith
I've been beating my head against the wall, reading, querying the internet, trying the 'solutions' I've found out there, but nothing's
helping me with this problem, so now I'm asking here.
I have a client laptop and a server. The server is running mySQL 8. Both systems are running python3. As I alluded to above, I've done all kinds of fiddling with the mySQL users, /etc/my.cnf, etc.
I have two users defined: root, and grunt. I can log into mysql on the server and do stuff - no problem.
From my laptop, I can do 'mysql -h "serverIP" -u 'root or grunt' -p and log into the server with no problem.
However when I try to execute a python3 script with the following code:
Code:
cnx = mysql.connector.connect(user='grunt',
password='xxxx',
host='192.168.1.100',
unix_socket='/tmp/mysqld.sock',
database='itunes')
I've tried using /var/run/mysqld/mysqld.sock and linking this to /tmp/mysqld.sock as you see in the code above. Nothing
affects the outcome which is the following message:
Code:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/mysql/connector/network.py", line 452, in open_connection
self.sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "./test.py", line 165, in srchit
artistSearchResults = myDB.doDB(searchterm)
File "./test.py", line 207, in doDB
database='itunes')
File "/usr/lib/python3/dist-packages/mysql/connector/__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "/usr/lib/python3/dist-packages/mysql/connector/connection.py", line 94, in __init__
self.connect(**kwargs)
File "/usr/lib/python3/dist-packages/mysql/connector/abstracts.py", line 722, in connect
self._open_connection()
File "/usr/lib/python3/dist-packages/mysql/connector/connection.py", line 207, in _open_connection
self._socket.open_connection()
File "/usr/lib/python3/dist-packages/mysql/connector/network.py", line 455, in open_connection
errno=2002, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2002: Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2 No such file or directory)
the first thing I wonder about is the part that says "Can't connect to local MySQl server...." seems to me that it should "REMOTE"
Second thing is...why can't it connect? What's different about my python script connecting and my sitting at the command line and connecting?
Any help would be GREATLY appreciated!
keith