What to do if you forget your MySQL password in Linux
##1. First edit the /etc/my.cnf file
vim /etc/my.cnf
# read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables
2. Restart the mysql service
service mysqld restart
3. Enter mysql
mysql
4. Execute the sql statements in sequence
>use mysql; 更改数据库 >UPDATE user SET PASSORD =password('你要设定的新密码') WHERE USER= 'root'; 重设密码 >flush privileges; 刷新MySQL的系统权限相关表,以防止更改后拒绝访问;或或者重启MySQL服务器 >quit;
Use
>update mysql.user set authentication_string=password('你要设定的新密码') where user='root' ;
5. Edit the /etc/my.cnf file again
vim /etc/my.cnf
6. Restart the mysql service
service mysqld restart
mysql -uroot -p
Linux system tutorial column, please continue to pay attention to this column for more related tutorials!
The above is the detailed content of What to do if you forget your MySQL password in Linux. For more information, please follow other related articles on the PHP Chinese website!