mysql忘记密码

centos

  1. 修改配置文件
vi /etc/my.cnf
在[mysqld]配置下面添加
skip-grant-tables
  1. 重启mysqld
systemctl restart mysqld
  1. 修改密码,刷新
update user set authentication_string=password('123abc') where user='root';
flush privileges;

赋权

GRANT ALL PRIVILEGES ON *.* TO 'tms'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  1. 恢复配置文件,重启mysqld

你可能感兴趣的:(mysql忘记密码)