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 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
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!