Home  >  Article  >  Database  >  Detailed explanation of how to change the password of mysql under Centos

Detailed explanation of how to change the password of mysql under Centos

黄舟
黄舟Original
2017-03-21 13:53:531451browse

This article mainly introduces the method of changing mysql password under Centos. Friends in need can refer to

1. Modify MySQL login settings:

# vim /etc/my.cnf

Add a sentence: skip-grant-tables

such as:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

2. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

3. Change password

mysql> USE mysql ;
Database changed
mysql> UPDATE user SET Password = password ( '新密码' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit

4. Modify the configuration file just changed

# vim /etc/my.cnf

5. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

The above is the detailed content of Detailed explanation of how to change the password of mysql under Centos. 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