DATABASE in settings file not working

166 views
Skip to first unread message

Detectedstealth

unread,
Feb 17, 2012, 9:11:11 AM2/17/12
to Django users
Hi,

I am just coming back to django development after a while of
developing with pyramid. I have taking over an application.

For some reason with the newest version of django it is not reading
the password I set in settings:

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

When starting the server I get the following error:
...MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/connections.py",
line 187, in
__init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user
'root'@'localhost' (using password: NO)")

Not sure why it is saying there was not password. For the newest
version of django is there a new way to tell python manage.py
runserver what password/username/database to use?

Detectedstealth

unread,
Feb 17, 2012, 9:59:19 AM2/17/12
to Django users
I have it working, however I need to provide the settings file when
running all commands:

python manage.py runserver --settings=settings

Babatunde Akinyanmi

unread,
Feb 17, 2012, 10:06:40 AM2/17/12
to django...@googlegroups.com
Try to connect to mysql with the same credentials on your terminal. If
it doesn't work then you need to reset your root password.

sudo dpkg-reconfigure mysql-server-5.1

Should do the trick and then restart the server (That works on ubuntu).

Also you should consider creating a separate user instead of using root.

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
Sent from my mobile device

Detectedstealth

unread,
Feb 17, 2012, 10:13:50 AM2/17/12
to Django users
I can connect with the same credentials that isn't the problem.

The problem is if I set a password in settings.py it doesn't use a
password as the error message states. However when I force the
settings file with the --settings option then it reads the file
correctly and uses the password.

On Feb 17, 7:06 am, Babatunde Akinyanmi <tundeba...@gmail.com> wrote:
> Try to connect to mysql with the same credentials on your terminal. If
> it doesn't work then you need to reset your root password.
>
> sudo dpkg-reconfigure mysql-server-5.1
>
> Should do the trick and then restart the server (That works on ubuntu).
>
> Also you should consider creating a separate user instead of using root.
>

Babatunde Akinyanmi

unread,
Feb 17, 2012, 10:45:41 AM2/17/12
to django...@googlegroups.com
Yes I do get it. I didn't realize that while I was typing my reply
your message had already been delivered to the group.

On 2/17/12, Detectedstealth <bruce...@gmail.com> wrote:

Furbee

unread,
Feb 17, 2012, 10:56:29 AM2/17/12
to django...@googlegroups.com
That is strange. This probably won't help, but try deleting the settings.pyc file and then run python manage.py runserver again (without --settings=settings).

Furbee

Detectedstealth

unread,
Feb 18, 2012, 12:04:30 AM2/18/12
to Django users
Yeah I have tried removing settings.pyc and __init__.pyc it
regenerates the *.pyc files but still is not reading the database
settings for some reason

On Feb 17, 7:56 am, Furbee <Furbeena...@gmail.com> wrote:
> That is strange. This probably won't help, but try deleting the
> settings.pyc file and then run python manage.py runserver again (without
> --settings=settings).
>
> Furbee
>
> On Fri, Feb 17, 2012 at 7:45 AM, Babatunde Akinyanmi
> <tundeba...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Yes I do get it. I didn't realize that while I was typing my reply
> > your message had already been delivered to the group.
>

Detectedstealth

unread,
Feb 18, 2012, 12:05:42 AM2/18/12
to Django users
I am starting to wonder if it is an opensuse bug. I am thinking about
switching back to Ubuntu.

Detectedstealth

unread,
Feb 18, 2012, 1:04:37 AM2/18/12
to Django users
Ok it looks like there is an issue with my desktop. I did everything
from scratch on my labtop (also running opensuse) and changes to the
settings file now work

dennis breland

unread,
Dec 11, 2014, 9:26:55 AM12/11/14
to django...@googlegroups.com

Please help with this problem...

 
I am getting an access denied error when running Django; details follow:

Currently installed versions:

            Python 2.7.3

MySQL-python package 1.2.3

            Django 1.7

 

I previously used the Django tutorial and successfully used the polling app, using sqlite3. Now I started over with the tutorial and I’m trying to use mysql instead. I created a database called denmain.

As stated in the tutorial, when I perform:

            python manage.py migrate

I get this response:

           

            File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__

    super(Connection, self).__init__(*args, **kwargs2)

django.db.utils.OperationalError: (1045, "Access denied for user 'dennis'@'localhost' (using password: NO)")

 

Here is my settings.py:

DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.mysql',

        'NAME': 'denmain',

        'USER': 'dennis',

        'PASSSWORD': 'mypass',

        'HOST': '127.0.0.1',

        'PORT': '3306',

    }

François Schiettecatte

unread,
Dec 11, 2014, 9:53:12 AM12/11/14
to django...@googlegroups.com
PASSSWORD => PASSWORD
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fd0f8b04-a8ff-41fc-8c77-01bd47abb679%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

dennis breland

unread,
Dec 11, 2014, 10:18:37 AM12/11/14
to django...@googlegroups.com
Thanks. I've spent hours on this silly typo.
Reply all
Reply to author
Forward
0 new messages