How to log in MySQL forgot password
- Edit mysql configuration file
vim /etc/my.cnf
....
'// 在文件的[mysqld]标签下添加一句:skip-grant-tables '
Then save and exit.
- Restart the database
systemctl restart mysqld
- Login mysql database without password
mysql -u root
- change Password
mysql> use mysql;
mysql> update mysql.user set authentication_string=password('abc123') where user='root';
'// 其中abc123为重新设置的密码,可以任意设置。'
- Comment out the skip-grant-tables added in step 1, and restart the server, you can log in to the server with the password you just modified.
mysql -uroot -pabc123