原来我用root用户,密码是abc,客户端都正常连接。
后来我执行了 grant all  on *.* to root@'192.168.0.%'.执行成功,客户端连接不用任何密码都可以成功连接,
但是现在我想回到原来的用密码连接的方式,执行
 grant all  on *.* to [email protected] identified by '12345678';执行报错:
Access denied for user 'root'@'192.168.0.119' (using password: YES)很奇怪,请问谁知道为什么?怎么恢复到需要密码连接。

解决方案 »

  1.   

    修改密码你用一下的方法
    update user set password=password('新密码') where user ='root';
    flush privileges;不过用grant all改密码我还从来没用过,不太清楚是什么原理
      

  2.   

    grant all  on *.* to root@'192.168.0.%'  这个并没有grant 权限 所以
    grant all  on *.* to [email protected] identified by '12345678';执行报错: 
    Access denied for user 'root'@'192.168.0.119' (using password: YES) 会报错;
      

  3.   

    show grants 贴一下结果看一下。
      

  4.   

    mysql> show grants;
    +-------------------------------------------------------+
    | Grants for [email protected]                         |
    +-------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.0.119' |
    +-------------------------------------------------------+
    1 row in set (0.05 sec)mysql>
      

  5.   

    以下是我自己的理解
    所谓赋权就是在mysql库中的user表加上一列数据
    你执行了 grant all  on *.* to root@'192.168.0.%'.执行成功
    是因为在user表中增加一行新的数据,这行数据的密码是空
    但你执行
    grant all  on *.* to [email protected] identified by '12345678';的时候
    这行数据是存在的,但是密码和你所写的密码是不同的,
    所以执行报错:
    Access denied for user 'root'@'192.168.0.119' (using password: YES) 你可以具体看下user这张表