Access denied for user 'root'@'localhost' (using password: YES)解决方案

来源:互联网 发布:windows下的脚本语言 编辑:程序博客网 时间:2024/04/19 19:15

这个问题困扰了我好几次,前几次出现这个问题,第二天莫名奇妙的就好了,现在我终于忍不了了,总的来说是权限问题,好了废话不多说,直接上解决方案:

  1. 在mysql的配置文件中添加skip-grant-tables(跳过密码直接进入mysql)
  2. 重启mysql:service mysqld restart
  3. 免密码进入mysql:mysql -uroot -p
    password:(直接回车)
  4. 给所有用户添加权限
    mysql> set global read_only=0;//(关掉新主库的只读属性)
    mysql>flush privileges;
    mysql>set global read_only=1;//(读写属性)
    mysql>flush privileges;
    mysql>grant all privileges on . to ‘root’@’%’ identified by ‘root’ with grant option;
    关键词解释:
    ‘root’@‘%’:是用户
    ‘root’:是密码

  5. 在mysql的配置文件中屏蔽掉skip-grant-tables

  6. 重启mysql:service mysqld restart
阅读全文
0 0
原创粉丝点击