Tameen Malik
Tameen Malik

Reputation: 1268

Django sql connection failed

I have created new project in django and write mysql connection in it's settings file like :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'optdb',
        'User': 'root',
        'Password':'975',
        'Host':'127.0.0.1',
        'Port':'8080',
    }
}

Now i write command : python manage.py syncdb and that generates following error:

enter image description here How to solve this error mentioned above? Note: I have currently one user in my MYSQL WAMP SERVER that is root with host 127.0.0.1.

Upvotes: 0

Views: 250

Answers (2)

frnhr
frnhr

Reputation: 12903

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'optdb',
        'USER': 'root',
        'PASSWORD':'975',
        'HOST':'127.0.0.1',
        'PORT':'8080',
    }
}

It's case sensitive...

Also, are you sure your mysql server is at port 8080? That's unusual. If unsure, just leave out that line and default mysql port will be used. See How can I connect to MySQL on a WAMP server?

Upvotes: 1

hcarver
hcarver

Reputation: 7234

All of those keys should be in capitals.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'optdb',
        'USER': 'root',
        'PASSWORD':'975',
        'HOST':'127.0.0.1',
        'PORT':'8080',
    }
}

Upvotes: 1

Related Questions