What should I do if I forget my mysql password?

Sometimes after installing lnmp, you will forget the mysql password. At this time, you need to modify the mysql configuration file to bypass the database password verification to reset the mysql password. The specific steps are as follows:

1. First confirm the working status of lnmp:      

If lnmp is running, close it first              

# /root/lnmp status 
# /root/lnmp stop

2. Enter the mysql configuration file:       

# vim /etc/my.cnf
Add a sentence to the paragraph of [mysqld]:              

skip-grant-tables

3. Start lnmp:                                    

# /root/lnmp start


4. Log in and modify the MySQL root password:            

//Start mysql

# /usr/bin/mysql

mysql> use mysql ; 
mysql> update user set Password = password ( 'new-password' ) where user = 'root' ;
mysql> exit

5. Modify the MySQL login settings back:              

# vim /etc/my.cnf
Delete the sentence previously added in the paragraph of [mysqld]: 

skip-grant-tables

6. Restart lnmp:                 

# /root/lnmp restart

Guess you like

Origin blog.csdn.net/chengshaolei2012/article/details/73251534
Recommended