[Django]-How to deal with this ERROR (1049, "Unknown database '/users/ohyunjun/work/astral/mysql'")

53πŸ‘

βœ…

'NAME' is the name of your database. With MySQL, you need to manually create your database too. Let’s say, if you run:

$ mysql -u root -p

mysql> CREATE DATABASE mydb;
Query OK, 1 row affected (0.02 sec)

your configuration should be:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydb',
        'USER': 'root',
        'PASSWORD': 'sp153426',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}
πŸ‘€Aylen

0πŸ‘

Hey man it just required that the database should already be created in MySQL.

0πŸ‘

I use docker to start mysql.

I changed the database name, then have same error.

After remove docker’s volume cache, thing be ok!

docker volume --help
docker volume ls
docker volume  rm xx yy

0πŸ‘

First you need to create database in Mysql database with the name which you write in your settings.py in mysql connectivuty code
settings.py

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'name_of database', 'USER': 'root', 'PASSWORD': 'sp153426', 'HOST': '127.0.0.1', 'PORT': '3306', } }

here name_of_database – is needed already in your database

create with sql query

           `CREATE DATABASE name_of Database;`

Leave a comment