Home >Database >Mysql Tutorial >What to do if you forget your password for Linux/Mac MySQL
Linux/Mac What should I do if I forget my password for MySQL? This article mainly introduces the solution to the MySQL forgotten password. The command line modification has certain reference value. Interested friends can refer to
Linux/Mac What to do if MySQL forgets the password? Don’t worry, here’s how to change your password using the command line.
All prerequisites require root permissions
1. End the mysql process
//Linux sudo services mysql stop //Mac brew services stop mysql
2. Mysql runs in the background
##
mysqld_safe --skip-grant-tables & mysql&, which means it runs in the background and does not open a new terminal
3. Change the password
use mysql; update user set password = password("新密码") where user='root'; flush privileges;If you know the original passwordUse the mysqladmin command on the command line
mysqladmin -u root -p oldpassword "newpassword"Or you can enter the mysql database to modify it directly, refer to the third part above [Change Password]
The above is the detailed content of What to do if you forget your password for Linux/Mac MySQL. For more information, please follow other related articles on the PHP Chinese website!