简体   繁体   中英

Django:1045, "Access denied for user

I have already read a lot of stack overflow questions for two days, but I can't figure it out the problem(I am using Mac).

I did : mysql -u root -p .

so it asked for the password, and root password is blank, no just an enter get me into mysql monitor and I received the message:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is xxx
Server version: 5.7.18 Homebrew

then: mysql> CREATE DATABASE concon CHARACTER SET utf8; .

so: mysql>CREATE USER 'concon'@'localhost' IDENTIFIED BY 'thepassword'; .

finally: mysql> GRANT ALL ON concon.* TO 'concon'@'localhost' .

So I exit mysql and run sudo python manage.py runserver

the problem is I receive: django.db.utils.OperationalError: (1045, "Access denied for user 'concon'@'localhost' (using password: YES)")

my dataBase is(in settings.py):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'concon',
        'USER': 'concon',
        'PASSWORD': 'thepassword',
        'HOST': 'localhost',
        'PORT': '',
    }
}

when I do : SHOW GRANTS FOR 'concon'@'localhost'; it shows:

+------------------------------------------------------------+
| Grants for concon@localhost                                |
+------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'concon'@'localhost'                 |
| GRANT ALL PRIVILEGES ON `concon`.* TO 'concon'@'localhost' |
+------------------------------------------------------------+

try this command: "mysql> FLUSH PRIVILEGES;" after you grant privileges to the user

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM