Home > Database > Mysql Tutorial > Solution to forgetting MySQL database password under Linux

Solution to forgetting MySQL database password under Linux

angryTom
Release: 2020-02-17 18:05:19
forward
2922 people have browsed it

This article introduces the solution to forget the Mysql password under Linux. I hope it will be helpful to friends who have this problem!

Solution to forgetting MySQL database password under Linux

Solution to forgetting the database password under Linux

1.vim /etc/my.cnf

2. Add a line skip-grant-tables under [mysqld], then save and exit.

3. Restart the mysql service: service mysqld restart.

4. Log in to mysql directly without a password -u root

(free learning video tutorial recommended: mysql video tutorial)

5. Modify through SQL root password

MySQL> UPDATE mysql.user SET Password=PASSWORD('新密码') where USER='root';
MySQL> flush privileges;
MySQL> exit
Copy after login

6. Modify the /etc/my.cnf file and delete the skip-grant-tables just added.

7. Restart mysql: service mysqld restart

8. You can log in with the new password: mysql -u root -p

The above is the detailed content of Solution to forgetting MySQL database password under Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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