when I used command "python manage.py makemigrations"(the same with typing "python manage.py runserver"),it threw this error.And then I checked the authority of the users. The code and result are as fllows.
mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| % | zhuxin |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | zhuxin |
+-----------+---------------+
mysql> show grants for 'zhuxin'@'%';
+---------------------------------------------------------------+
| Grants for zhuxin@% |
+---------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zhuxin'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'zhuxin'@'%' |
+---------------------------------------------------------------+
mysql> show grants for 'root'@'%';
+--------------------------------------------------+
| Grants for root@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'root'@'%' |
+--------------------------------------------------+
I have tried everything to solve it, but for no use.
You need to make changes in project settings.py. Provide USER
and PASSWORD
for your database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'root',
'PASSWORD': 'rootpassword',
'HOST': 'localhost',
'PORT': '',
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With