This article will use examples to introduce to you two methods of lnmp resetting the root password of the mysql database. The first method is to reset the password through a script, and the second method is to modify it through commands. Please refer to this article for specific operation methods. I hope you can Help everyone.
The first method: Use Jun Ge’s one-click script to modify the MYSQL database password in the LNMP environment
The one-click script is definitely very convenient. Specifically execute the following command:
wget http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh sh reset_mysql_root_password.sh
Convenience!
Second method: Modify through commands, as follows:
a. Stop the MySQL service
Execution: /etc/init.d/ mysql stop
b, skip verification and start MySQL
/usr/local/mysql/bin/mysqld_safe –skip-grant-tables >/dev/null 2>&1 &
Then:
mysql mysql -uroot //登陆 mysql> UPDATE user SET Password=PASSWORD(‘new password') where USER='root'; mysql> FLUSH PRIVILEGES; mysql> quit
Then restart mysql
/etc/init.d/mysql start
Related recommendations:
How to reset MySQL’s Root password
MySQL-How to operate if you forget the Root password
The above is the detailed content of Two lnmp methods to reset mysql database root password. For more information, please follow other related articles on the PHP Chinese website!