Reset the MySQL root Password in CentOS

Source: Internet
Author: User

Reset the MySQL root Password in CentOS

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


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


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.

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


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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.