Reputation: 39
When i run the code below in python 2.7.7, i get the error also below.
code:
import MySQLdb
db = MySQLdb.connect(
host="localhost",
port=3306,
user="root",
passwd="mypassword",
db="python"
)
error:
'_mysql_exceptions.OperationalError: (1049, "Unknown database 'python'")'
The database was made using MySQL Workbench and saved to the desktop (same location as python file) with the name python. I'm not using Django or anything like that and can't find answers where the person isn't using it. Please help.
Upvotes: 1
Views: 5955
Reputation: 6439
MySQL Workbench produces a .mwb
file which is not a database. This file is only a Entity-Relationship schema (which is very useful).
You have to export a SQL create script
of your schema.
Menu File > Export > Forward Engineer SQL CREATE script
Then you execute this script (a .sql
file) that will create your database.
For example, you can do it with :
Your schema have to be like this in your case (database name) :
For your information a MySQL database is used through an IP/port, not through a file (SQLite is a file database for example, not MySQL).
Upvotes: 5