Reputation: 83
my Settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'DATABASE' : 'DjangoProject',
'USER' : 'myprojectuser',
'PASSWORD' : 'Akbar@123456',
'HOST': 'localhost',
'PORT': '',
# 'default-character-se' : 'utf8',
# 'NAME': BASE_DIR / 'db.sqlite3',
}
}
SHOW DATABASES command on terminal
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| DjangoProject |
| information_schema |
| mysql |
| performance_schema |
| sample |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql>
error
File "/usr/local/lib/python3.8/dist-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.8/dist-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1046, 'No database selected')
I have granted the user rights on the database but it still showing error, please help i want to run mySql just like sqlite3 where you can see your databases in the admin panel, and works same once settings are made, please tell if there is gui interface for mySQL and also how to see your database on the browser,
Upvotes: 0
Views: 239
Reputation: 2334
You are missing NAME
in DATABASE dictionary
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'DATABASE' : 'DjangoProject',
'USER' : 'myprojectuser',
'PASSWORD' : 'Akbar@123456',
'HOST': 'localhost',
'PORT': '',
# 'default-character-se' : 'utf8',
'NAME': 'DjangoProject',
}
}
Upvotes: 1