cenos系统python项目报错mysql Access denied for user root@localhost错误解决方法

来源:互联网 发布:苹果6网络通信出现问题 编辑:程序博客网 时间:2024/05/01 14:35

配置MySQL允许root用户远程登录


步骤:

  1. 修改root密码 (可选)

    # 切换到mysql这个数据库mysql> use mysql;# 将root用户的密码修改为:123456mysql> update user set password=PASSWORD('123456') where user='root';
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  2. 检查root配置

    # root用户登录$ mysql -u root -p# 切换到mysql这个数据库mysql> use mysql;# 查看root用户配置mysql> select host,user from user where user='root';
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  3. 修改root配置 

    如果查询结果中不包含以下记录,请添加,否则请忽略次步骤

    hostuser%root

    mysql> update user set host = ‘%’ where user = ‘root’ and host=’127.0.0.1’;

  4. 给用户授权

    mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
    • 1
    • 2
  5. 使配置生效

    mysql> flush privileges;
    • 1
    • 2

配置完成,客户端重新登录成功;

参考文章:http://blog.csdn.net/xiongyu1010/article/details/52229988


阅读全文
0 0
原创粉丝点击