I\'ve started working with django, and here is the error on \'runserver\' after setting up \'DATABASES\' in settings.py
mysql_exceptions.OperationalError: (1
After struggling for two days I finally found whats wrong. Entire steps to set up a mysql database for Django site are-
Your settings.py file must look like-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_db', #Name of database you created
'USER': 'root', #Username of database you created
'PASSWORD':'', #Password of database you created
'HOST': '',
'PORT': '',
} }
Note:-The password and username given above is of my localhost you have change it to yours.
create a database in localhost let name it django_db (for this you can use lamp/wamp/Xampp or mysql command prompt)
Edit the file settings.py and save the password you require to open your database in DATABASES field as given below in the code.
open terminal.
If you are using virtual environment then switch into it by using command -> workon env_name
Now cd app_name eg. cd mysite
step 3, 4 and 5 just tells how to reach the folder where manage.py file found in your Application.
6.To check you are in right directory run command ls -l. If you find manage.py file then everything is right go ahead
7.python manage.py migrate
If you are having any error like- "No module named MySQLdb" in running above command you can visit the link
8.python manage.py syncdb
9.python manage.py runserver
10.You will be asked for username and password for your Django admin, give whatever you want to open Django admin site.
11.check you are having some tables in your database in localhost at `http://localhost/phpmyadmin. You are good to go now.