Home > Database > Mysql Tutorial > What to do if you forget your password for Linux/Mac MySQL

What to do if you forget your password for Linux/Mac MySQL

巴扎黑
Release: 2017-05-14 14:19:25
Original
1043 people have browsed it

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
Copy after login

2. Mysql runs in the background


##

mysqld_safe --skip-grant-tables &
mysql
Copy after login

&, 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;
Copy after login

If you know the original password

Use the mysqladmin command on the command line



mysqladmin -u root -p oldpassword "newpassword"
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template