解决方法:
# 进入mysql
mysql -u root =p
# 进入项目使用的数据库
use test
# 运行
grant usage on *.* to root@localhost identified by 'password'; # password是进入MySQL设置的密码
GRANT all privileges on DBNAME.* to 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
重新生成迁移文件: python manage.py makemigrations
应用数据库迁移: python manage.py migrate