django.db.utils.operationalerror: (1046, 'no database selected')

  • Last Update :
  • Techknowledgy :

Check to make sure your database my_db exists in your MySQL instance. Log into MySQL and run;

show databases;

make sure my_db exists. If it does not, run

create database my_db;

GRANT access privileges to the user mentioned in the file

GRANT ALL PRIVILEGES ON database_name.*TO 'username'
@ 'localhost';

Suggestion : 2

Getting a strange error. I created a database in MySQL, set the database to use it. Using the right settings in my Django settings.py. But still there's an error that no database has been selected., 1 week ago I'm attempting to generate a QuerySet that collects all the tags that are posted in all of a given user's posted questions. On top of that, annotate … , 1 week ago Dec 17, 2015  · 2 Answers. Sorted by: 6. Check to make sure your database my_db exists in your MySQL instance. Log into MySQL and run; show databases; make sure my_db exists. If it does not, run. create database my_db; , 5 days ago Hey, r/djangolearning.I'm building an (American) football simulation game with Django for practice and would appreciate some feedback on my model design so far.


python manage.py syncdb
python manage.py syncdb
django.db.utils.OperationalError: (1046, 'No database selected')
DATABASES = {
   'default': {
      'ENGINE': 'django.db.backends.mysql',
      'NAME': 'my_db',
      'USER': 'username',
      'PASSWORD': 'password',
      'HOST': 'localhost',
      'PORT': '3306',
   }
}
show databases;
create database my_db;

Suggestion : 3

django test app error - Got an error creating the test database: permission denied to create database,Django - OperationalError - attempt to write a readonly database,Django : How to get longitude and latitude from google maps user selected adress and save to database,Getting a css ribbon to appear on selected images only from a django database

GRANT access privileges to the user mentioned in the file

GRANT ALL PRIVILEGES ON database_name.*TO 'username'
@ 'localhost';

Check to make sure your database my_db exists in your MySQL instance. Log into MySQL and run;

show databases;

make sure my_db exists. If it does not, run

create database my_db;

Suggestion : 4

How can I get only the time range from the given figure in firebase realtime database using Flutter?,When using set state hooks in a text input field, React thinks I'm changing the value to undefined,UIAlertController not getting deallocated,I have granted the user rights on the anycodings_ubuntu database but it still showing error, please anycodings_ubuntu help i want to run mySql just like sqlite3 anycodings_ubuntu where you can see your databases in the anycodings_ubuntu admin panel, and works same once settings anycodings_ubuntu are made, please tell if there is gui anycodings_ubuntu interface for mySQL and also how to see your anycodings_ubuntu database on the browser,

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')

You are missing NAME in DATABASE anycodings_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',
   }
}