设为首页 加入收藏

TOP

CentOS 下 MySQL root 密码重置
2015-08-31 19:59:49 来源: 作者: 【 】 浏览:38
Tags:CentOS MySQL root 密码 重置

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


#service mysqld stop


输出


Shutting down MySQL.? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [? OK? ]


二、启动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.5 平台离线编译安装 MyS.. 下一篇利用MySQL-Proxy进行MySQL数据库..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)