What should I do if I forget mysq password?

Find the mysql configuration file my.cnf

find / -name my.cnf

Edit my.cnf

vim my.cnf

#在[mysqld]  下方添加
skip-grant-tables

# 然后保存退出

restart mysql

There is no need to enter a password to enter mysql at this time

mysql -uroot -p  
#  -u后面跟用户名

Update the user table password in the mysql library

#设置新密码
update mysql.user set authentication_string=password(<

Guess you like

Origin blog.csdn.net/hyrylt/article/details/125789070