私はMac(OS 10.10.5)、PyCharm、Python 3.5、MySQLを使用しています。 MySQLは同じマシン上でPHPを使用しています。 (8ノード名もservnameのが知られて、またはしない)Pythonのmysql.connectorを使ってmysqlに接続できません
「3306 :: localhost」の上でMySQLサーバに接続することはできません: enter code here
2003:私は、Pythonを使用して、エラーメッセージを取得し、それに接続しようとしています私は問題を解決することができるように誰かが診断手順を記載していますか?おかげで、以下
ダグ
は、接続コードです:mysql.connectorインポートエラーコードから 輸入mysql.connectortry:
cnn = mysql.connector.connect(
host="localhost:", # your host, usually localhost
user="root", # your username
password="root", # your password
database="bb_cards") # name of the data base
print("It Works!!")
except mysql.connector.Error as e:
if e.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with username or Password")
elif e.errno == errorcode.ER_BAD_DB_ERROR:
print("Database Does not exist")
else:
print(e)