python 连接数据库,显示 Host is not allowed to connect to this MySQL server

发布于 更新于
本文目录
  1. Host is not allowed to connect to this MySQL server

技术文章Linux与数据库

当python连接数据库时,报错显示:

当python连接数据库时,报错显示:

Host is not allowed to connect to this MySQL server

这个错误其实就是我们的数据库不允许远程登录;

解决办法如下:

  1. 打开cmd命令窗口,输入 mysql -uroot -p ,输入密码后进入MySQL

  2. 使用mysql,继续输入 use mysql;,回车

  3. 继续输入 update user set host = '%' where user = 'root'; 更改root权限

  4. flush privileges ,最后加载权限表,就成功了,再去python中运行报错解决了!

来源:testingpai

继续阅读