Django 无法链接mysql数据库
自己写的python 脚本可以连接上数据库,
pymysql.connect(host = host, user = username, password=pwd, database = database_name)
但是启动Django 整个服务的时候就无法链接上了
运行结果及报错内容
/root/.local/lib/python3.6/site-packages/paramiko/transport.py:169: CryptographyDeprecationWarning: Blowfish has been deprecated
'class': algorithms.Blowfish,
System check identified no issues (0 silenced).
Unhandled exception in thread started by .wrapper at 0x7fcf8f215e18>
Traceback (most recent call last):
File "/root/.local/lib/python3.6/site-packages/pymysql/connections.py", line 614, in connect
(self.host, self.port), self.connect_timeout, **kwargs
File "/usr/local/python3/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/local/python3/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'xx.db.com' ([Errno 111] Connection refused)")
python3.6, 和3.7都报一样的错