This article mainly introduces Linux/Mac MySQLForgot password command line method to change password, friends in need can refer to it
All prerequisites are Need to obtain root permission
1.End the mysql process
//Linux sudo services mysql stop //Mac brew services stop mysql
2.mysql background running
mysqld_safe --skip-grant-tables & mysql
&, means Run in the background without opening a new terminal
3. Change the password
use mysql; update user set password = password("新密码") where user='root'; flush privileges;
If you know the original password
Use the mysqladmin command on the command line You can
mysqladmin -u root -p oldpassword "newpassword"
or you can enter the mysql database to modify it directly. Please refer to the third part above [Change Password]
[Related Recommendations]
1 . Free mysql online video tutorial
2. MySQL latest manual tutorial
3. Those things about database design
The above is the detailed content of What to do if you forget your MySQL password in Linux? Steps to change password on command line. For more information, please follow other related articles on the PHP Chinese website!