mysql5.7初始密码查看及密码重置

查看初始密码

  • grep 'temporary password' /var/log/mysqld.log
  • cat /root/.mysql_secret
    mysql密码找回

密码重置

vi /etc/my.cnf

在[mysqld]下加上 skip-grant-tables,如:

[mysqld] 
datadir=/var/lib/mysql 
socket=/var/lib/mysql/mysql.sock 
skip-grant-tables 
  • 重启mysql
    service mysqld restart

  • 登陆mysql后就可以修改密码了
    mysql -u root

    update mysql.user set authentication_string=PASSWORD('123456') where User='root';
    flush privileges;

参考文献:https://www.jianshu.com/p/0a40cbaa79a0

你可能感兴趣的:(数据库)