在虚拟机中部署项目,迁移数据库执行python manage.py migrate报错(1698, "Access denied for user 'root'@'localhost'")

在虚拟机中部署项目,迁移数据库执行python manage.py migrate报错(1698, “Access denied for user ‘root’@‘localhost’”)

sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1698, “Access denied for user ‘root’@‘localhost’”)
(Background on this error at: http://sqlalche.me/e/2j85)

原因可能是因为Ubuntu系统不允许root用户直接远程访问,需要授权才行
我们进入mysql
GRANT ALL PRIVILEGES ON . TO root@"%" IDENTIFIED BY “root”;

flush privileges;
在这里插入图片描述
给root授权,然后刷新权限,

但是依旧报错
在这里插入图片描述
再次进如查看mysqlroot的权限以及密码
在这里插入图片描述

root以及有了远程连接 % 的权限,但是root的密码为空

如果在Ubuntu上安装mysql时没有设置密码,那么就再重新设置一次

update mysql.user set authentication_string=‘yy0424…’ where user=‘root’ and Host =‘localhost’;
update user set plugin=“mysql_native_password”;
flush privileges;
在这里插入图片描述
再次回到项目中迁移数据库
在这里插入图片描述
成功!!!

发布了65 篇原创文章 · 获赞 41 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_43870646/article/details/103407801