python链接mysql报错2003_连接到数据库时出现“接口错误:2003”

我正在尝试使用MySQL Connection/Python连接到我的数据库。

这是我得到的结果:Traceback (most recent call last):

File "bh2000.py", line 33, in

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)

下面是我使用的代码:import mysql.connector

cnx = mysql.connector.connect(user='xxx', password='xxx',

host='xxx.db.1and1.com',

database='xxx')

cnx.close()

我哪里做错了?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值