Home  >  Article  >  Database  >  Two lnmp methods to reset mysql database root password

Two lnmp methods to reset mysql database root password

小云云
小云云Original
2017-12-25 13:59:452260browse

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

Introduction to the methods of changing the root password and installation and configuration tuning in MySQL

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!

Statement:
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