Home > Database > Mysql Tutorial > What to do if you forget your MySQL password in Linux? Steps to change password on command line

What to do if you forget your MySQL password in Linux? Steps to change password on command line

零下一度
Release: 2017-05-11 14:59:04
Original
1574 people have browsed it

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

2.mysql background running

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

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

If you know the original password

Use the mysqladmin command on the command line You can

mysqladmin -u root -p oldpassword "newpassword"
Copy after login

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!

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