1049, "Database unknown database" "django mysql cannot connect

Exception Type: OperationalError at / Exception Value: (1049, "Unknown database 'database'") 

Currently I have tried this:

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'database', # Or path to database file if using sqlite3. 'USER': 'root', # Not used with sqlite3. 'PASSWORD': '****', # Not used with sqlite3. 'HOST': '/var/lib/mysql/database/', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '80', # Set to empty string for default. Not used with sqlite3. } } 

If I do not specify the host, I get this error:

 OperationalError at / (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/database' (13)") 

Could there be something with permissions?

early:)

+4
source share
3 answers

First create a database on mysql. Secondly, edit your standard link this way.

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'MY_DATABASE_NAME', 'USER': 'root', 'PASSWORD': 'MY_PASSWORD', } } 

finally run your syncdb.

./manage.py syncdb

+5
source

PORT is not a web server port, but database port 3306 for MySQL and HOST is the IP address or database name. You probably want 127.0.0.1 .

You must create the database in advance using create database mydatabase charset utf8; from the mysql prompt.

+5
source

I do not think you can create a database using a database of names. Therefore, first check the following:

1) Have you installed a mysql server and created a database with proper granting of all permissions? If you have done this, check the following steps.

2) I do not know about Amazon, but this error was common in older versions of Linux distributions from Redhat and Fedora. This must be done by setting the SELINUX line in / etc / sysconfig / selinux to Disabled:

SELINUX = Off

0
source

All Articles