Reputation:
I had installed mysql and on python shell import MySQLdb
does work. I also changed the settings.py as:
**DATABASE_ENGINE = 'mysql'
DATABASE_NAME = '/home/database/my_db.db'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''**
but when I test for the connection it fails.
terminal:
>>> from django.db import connection
>>> cursor = connection.cursor()
It gives the error as :
OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysql' (2)")
Upvotes: 2
Views: 4668
Reputation: 55972
Django say its engine should be https://docs.djangoproject.com/en/dev/ref/settings/#engine 'django.db.backends.mysql'
I think database name is the name of the database inside mysql not a path. A path is just for sqlite. Do you have mysql server running?
USER, PASSWORD are required. host defaults to localhost port defualts to 3306.
Upvotes: 1
Reputation: 11779
Are you running a MySQL server? is it on:
also, database name is name as mysql understands it, not a file path.
Upvotes: 1