Mysql修改数据库密码

Mysql忘记密码,修改密码

  • 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

原文地址:http://biyongyao.com/archives/206

猜你喜欢

转载自blog.csdn.net/biyongyao/article/details/78155563