无法连接IMOOC数据库 IMOOC数据库已经创建
import MySQLdb
conn = MySQLdb.Connect(
host = '127.0.0.1',
port = 3306,
user = 'root',
passwd = '',
db = 'imooc',
charset = 'utf8'
)
cursor = conn.cursor()
print conn
print cursor
cursor.close()
conn.close()
提示
Traceback (most recent call last):
File "D:\eclipseee\immoc\com\imooc\test_connecton.py", line 9, in <module>
charset = 'utf8'
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 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1049, "Unknown database 'imooc'")
IMOOC数据库已经创建,但是如果将IMOOC改成MYSQL或者系统默认的就可以运行,自己添加到都无法运行 请问为什么