mysql 的接口错误
Interface Error of mysql
我安装了 mysql connector/python 并且正在使用 MAMP。当我尝试连接到数据库时,这是终端中出现的内容:
Traceback (most recent call last):
File "database.py", line 7, in <module>
raise_on_warnings= True)
File "/Library/Python/2.7/site-packages/mysql/connector/__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 95, in __init__
self.connect(**kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/abstracts.py", line 719, in connect
self._open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 206, in _open_connection
self._socket.open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/network.py", line 475, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:8889:3306' (60 Operation timed out)
我尝试进入 连接器文件夹 并检查了 network.py 脚本,看来错误是由于接口错误造成的。文档说:
This exception is raised for errors originating from Connector/Python itself, not related to the MySQL server.
errors.InterfaceError is a subclass of errors.Error
如果需要,这是我的 python 脚本:
import mysql.connector
con = mysql.connector.connect(user='root',
password ='root',
host='localhost',
database='testdb',
raise_on_warnings= True)
cur = con.cursor()
cur.close()
con.close()
如何消除界面错误?
从您的主机中删除端口号和冒号:
con = mysql.connector.connect(user='root',
password ='root',
host='localhost',
database='testdb',
raise_on_warnings= True)
您的端口已设置为 3306
我安装了 mysql connector/python 并且正在使用 MAMP。当我尝试连接到数据库时,这是终端中出现的内容:
Traceback (most recent call last):
File "database.py", line 7, in <module>
raise_on_warnings= True)
File "/Library/Python/2.7/site-packages/mysql/connector/__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 95, in __init__
self.connect(**kwargs)
File "/Library/Python/2.7/site-packages/mysql/connector/abstracts.py", line 719, in connect
self._open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 206, in _open_connection
self._socket.open_connection()
File "/Library/Python/2.7/site-packages/mysql/connector/network.py", line 475, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:8889:3306' (60 Operation timed out)
我尝试进入 连接器文件夹 并检查了 network.py 脚本,看来错误是由于接口错误造成的。文档说:
This exception is raised for errors originating from Connector/Python itself, not related to the MySQL server.
errors.InterfaceError is a subclass of errors.Error
如果需要,这是我的 python 脚本:
import mysql.connector
con = mysql.connector.connect(user='root',
password ='root',
host='localhost',
database='testdb',
raise_on_warnings= True)
cur = con.cursor()
cur.close()
con.close()
如何消除界面错误?
从您的主机中删除端口号和冒号:
con = mysql.connector.connect(user='root',
password ='root',
host='localhost',
database='testdb',
raise_on_warnings= True)
您的端口已设置为 3306