기본 MySQL을 배우면서 파이썬에 넣기로 결정했습니다. .이 MySQL 서버에서 작동하는 PHP 스크립트가 있으므로 서버가 작동 중임을 알고 있습니다. 하지만 내가 연결할 때마다이 오류가 발생합니다.OperationalError : (2003, " 'mysql2.000webhost.com'(10060)의 MySQL 서버에 연결할 수 없습니다.)
Traceback (most recent call last):
File "E:/Geekster_Bot/Geekster_Bot Code/Geekster_Bot_alpha_API_MySQL", line 6, in <module>
db="MY DATABASE")# name of the data base
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'mysql2.000webhost.com' (10060)")
임 확실하지 않습니다. 나는 MySQL 포트 (3306)를 열었고 내가 말한 것처럼 서버/데이터베이스가 작동 중이다. 어떤 아이디어?
이것은 전체 MySQL 연결의 코드입니다.
import MySQLdb
db = MySQLdb.connect(host="mysql2.000webhost.com", # your host, usually localhost
user="MY USER", # your username
passwd="MY PASSWORD", # your password
db="MY DATABASE")# name of the data base
#you must create a Cursor object. It will let
#you execute all the queries you need
cur = db.cursor()
#Use all the SQL you like
cur.execute("SELECT * twitch_follows_ign")
#print all the first cell of all the rows
for row in cur.fetchall() :
print row[0]
차단 된 모든 데이터가 올바르게 입력됩니다.
000webhost는 외부 MySQL 연결을 허용하지 않으며 무료 계정에 Python 지원이 없으므로 오류의 원인이되는 호스트 컴퓨터에서이를 실행하지 않는 것으로 가정합니다. –