0

I have setup the MySQL database in django. but I am getting the operational error such as unknown database.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    #'ENGINE': 'mysql.connector.django',
    'NAME': os.path.join(BASE_DIR, 'dbname'),
    'USER':'root',
    'PASSWORD':'********',
    'HOST':'localhost',
    'PORT':'3306',
}

}

But it throws following error:

django.db.utils.OperationalError: (1049, "Unknown database 'c:\users\brahmareddy\desktop\djangotable\checkingapp\djangodb'")

1
  • 2
    the 'ENGINE' is 'django.db.backends.mysql' but you want to connect to 'c:\users\brahmareddy\desktop\djangotable\checkingapp\dbname' -- I think it is sqlite. Commented Apr 2, 2019 at 7:40

2 Answers 2

1

your setting for mysql database should look like this

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'DB_NAME',
        'USER': 'DB_USER',
        'PASSWORD': 'DB_PASSWORD',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

Name should not contain path, it is just the name of already running MySQL instance

Host is the IP Address of the MySQL server

Sign up to request clarification or add additional context in comments.

2 Comments

i used this these parameters. but again its throws the same error.
can you paste the error here? also do have MSSql instance running somewhere with whom you want to connect to?
0

If you use docker, maybe you should check the docker volume.

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

Remove cache, restart.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.