lnmp Two Methods of Resetting root Password in mysql Database
- 2021-08-31 09:34:04
- OfStack
The first method: Modify the password script of MYSQL database under LNMP environment with the 1 key of Junge
1-key scripts are definitely very convenient. Execute the following orders:
wget http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh
sh reset_mysql_root_password.sh
Convenient!
Method 2: Modify by command, as follows:
a, stop MySQL service
Execute:/etc/init. d/mysql stop
b, skip validation and start MySQL
/usr/local/mysql/bin/mysqld_safe In fact, in fact, the skip-grant-tables >/dev/null 2>&1 &
Then:
mysql mysql -uroot // Landing
mysql> UPDATE user SET Password=PASSWORD( ' new password') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
Then restart mysql
/etc/init.d/mysql start
Summarize