I'm trying to use MySQL Connection/Python to connect to my database.
Here's the output I'm getting:
Traceback (most recent call last):
File "bh2000.py", line 33, in <module>
cnx = mysql.connector.connect(**config)
File "/Library/Python/2.7/site-packages/mysql/connector/__init__.py", line 155, in connect
return MySQLConnection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 123, in __init__
self.connect(**kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 430, in connect
self._open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 393, in _open_connection
self._socket.open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/network.py", line 375, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'host xxx.db.1and1.com:3306' (8 nodename nor servname provided, or not known)
Here's the code I'm using:
import mysql.connector
cnx = mysql.connector.connect(user='xxx', password='xxx',
host='xxx.db.1and1.com',
database='xxx')
cnx.close()
Where am I going wrong?
Default port if not specified is 3306. Otherwise there is nothing wrong with your code. The problem is with your MySQL server or the connection is being blocked by your firewall or the server firewall. Make sure port 3306 is open and not blocked.
db = mysql.connector.connect(user='xxx', password='xxx', host='xxx.db.1and1.com', port=3306)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With