There are many ways to reset the MySQL password in CentOS. The official website also provides convenient and quick operations. For more information, see resettingpermissions. This document resets the password
There are many ways to reset the MySQL password in CentOS. The official website also provides convenient and quick operations. For details, refer to resetting permissions. This document resets the password
There are many ways to reset the MySQL password in CentOS. The official website also provides convenient and quick operations. For details, refer to resetting permissions. To reset the password, follow these steps:
1. Stop MySQL (if it is running)
# Service mysqld stop
Output
Shutting down MySQL. [OK]
For the # service mysqld stop command, refer to CentOS 6.5 offline compilation and installation of MySQL 5.6.22.
2. Start MySQL_safe, so you can log on to MySQL without a password.
# Mysqld_safe -- skip-grant-tables &
Output is similar
Starting mysqld daemon with databases from/var/lib/mysql
Mysqld_safe [6025]: started
3. log on to MYSQL
# Mysql-u root
Output
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
4. Set a new password
Mysql> use mysql;
Mysql> update user set password = PASSWORD ("NEW-ROOT-PASSWORD") where User = 'root ';
Mysql> flush privileges;
Mysql> quit
5. Stop MySQL
#/Etc/init. d/mysql stop
Output
Stopping MySQL database server: mysqld
STOPPING server from pid file/var/run/mysqld. pid
Mysqld_safe [6186]: ended
[1] + Done mysqld_safe -- skip-grant-tables
6. Start MySQL and test whether the new password is correct.
#/Etc/init. d/mysql start
# Mysql-u root-p
How to reset the root password after installing MySQL in CentOS 6.4
This article permanently updates the link address: