Problem in django tutorial 5 , 1044 Access denied for user @'localhost' database error

1,371 views
Skip to first unread message

Shashank Yadav

unread,
Jan 12, 2017, 7:11:54 AM1/12/17
to Django users
Hello,

I am working on tutorial 5 , i tried running a test:

$ python manage.py test polls
Creating test database for alias 'default'...
Got an error creating the test database: (1044, "Access denied for user 'myprojectuser'@'localhost' to database 'test_myproject'")
Type 'yes' if you would like to try deleting the test database 'test_myproject', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Got an error recreating the test database: (1044, "Access denied for user 'myprojectuser'@'localhost' to database 'test_myproject'")


I have tried mentioning the test_name in settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'myproject',
        'USER': 'myprojectuser',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '',
        'TEST_NAME': 'test_database_myprojecttest',
    }
}

I also ran
,"GRANT ALL PRIVILEGES ON test_myproject TO 'myprojectuser'@'localhost';" , in mysql


Still cannot run the test. What should i do ?


Andreas Kuhne

unread,
Jan 12, 2017, 7:21:22 AM1/12/17
to django...@googlegroups.com
You need to have the database create permission as well. Otherwise django can't recreate the database. What happens when you start the tests is that the database is dropped and recreated each time.

Regards,

Andréas

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/482263d6-f640-46c0-928e-f532e0b6c838%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Melvyn Sopacua

unread,
Jan 12, 2017, 7:55:45 AM1/12/17
to django...@googlegroups.com

On Thursday 12 January 2017 01:24:05 Shashank Yadav wrote:

 

 

> $ python manage.py test polls

> Creating test database for alias 'default'...

> Got an error creating the test database: (1044, "Access denied for

> user 'myprojectuser'@'localhost' to database 'test_myproject'")

 

> I also ran ,"GRANT ALL PRIVILEGES ON test_myproject TO

> 'myprojectuser'@'localhost';" , in mysql

 

This isn't the same as:

GRANT ALL PRIVILEGES ON test_myproject.* TO ...;

 

which is what you need. Yes, I'm making you look for the difference, so you don't forget ;)

--

Melvyn Sopacua

Reply all
Reply to author
Forward
0 new messages