• vim /etc/my.cnf
  • 在 [mysqld] 中加上一行跳过权限限制 skip-grant-tables
  • service mysqld restart
  • mysql -uroot -p (直接点击回车,密码为空)
  • use mysql;
  • mysql> update user set password=password('123') where user='root'; //5.6

    mysql> update user set authentication_string=password('new password') where user='root';//5.7

    mysql> flush privileges;

  • 退出mysql 删除skip-grant-tables

  • service mysqld restart