Home > Database > Mysql Tutorial > body text

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

黄舟
Release: 2017-03-21 13:53:53
Original
1403 people have browsed it

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
Copy after login
Copy after login

Add a sentence: skip-grant-tables

such as:

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

2. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
Copy after login
Copy after login

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
Copy after login

4. Modify the configuration file just changed

# vim /etc/my.cnf
Copy after login
Copy after login

5. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!