Home  >  Article  >  Database  >  CentOS 下 MySQL root 密码重置

CentOS 下 MySQL root 密码重置

WBOY
WBOYOriginal
2016-06-07 15:21:331110browse

CentOS 下 重置MySQL密码的方法有很多,官网也提供了很方便的快捷操作办法,可参考资料 resetting permissions 。本文重置密码的

CentOS 下 重置MySQL密码的方法有很多,官网也提供了很方便的快捷操作办法,可参考资料 resetting permissions 。本文重置密码的具体步骤如下:

一、停止MySQL(如果处于运行状态)

#service mysqld stop

输出

Shutting down MySQL.                                      [  OK  ]

关于 #service mysqld stop 命令,,可参考 CentOS 6.5 平台离线编译安装 MySQL 5.6.22。

二、启动MySQL_safe,如此以来便可不用密码登录MySQL

# mysqld_safe --skip-grant-tables &

输出类似

Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

三、登录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.
mysql>

四、设置新密码

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

五、停止MySQL

# /etc/init.d/mysql stop

输出

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+  Done                    mysqld_safe --skip-grant-tables

六、启动MySQL并测试新密码是否正确

# /etc/init.d/mysql start
# mysql -u root -p

CentOS 6.4下安装MySQL后重置root密码方法

本文永久更新链接地址

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
Previous article:Oracle ascii函数Next article:HBase快速导入数据--BulkLoad