我有一个MAMP服务器数据库,它拥有所有用户的所有权限。我试图通过python文件连接到数据库。它显示以下错误:
File "mymodule.py", line 3, in <module>
con = mdb.connect('localhost','root','root','network')
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.12-intel.egg/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.12-intel.egg/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1049, "Unknown database 'network'")
我的代码是
import MySQLdb as mdb
con = mdb.connect('localhost','root','root','network')
with con:
cur = con.cursor()
cur.execute("INSERT INTO trial(count) values(100)")
这个数据库不是问题。它是所有数据库的问题。我无法连接任何一个。请指导。