MySQL修改密码

  1. 错误方法

    网上大部分教程使用如下命令:
    mysql> set password for root@localhost = password('123456');
    结果报错:
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near'password('123456')' at line 1
  2. 正确方法

    1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123';
    2. mysql> set password = ('123');