mysql的root密码重置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql的root密码重置相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# mysqladmin -uroot password ‘123456‘ 给MySQL设置一个密码
[[email protected] ~]# mysqladmin -uroot password ‘123456‘ 本地登录MySQL
假如我们现在MySQL密码已忘记,现在进行重置。
[[email protected] ~]# vim /etc/my.cnf 编辑配置文件
skip-grant 加入这个保存退出(不授权直接可以登录)
[[email protected] ~]# /etc/init.d/mysqld restart 重启一下MySQL Shutting down MySQL..... SUCCESS! Starting MySQL. SUCCESS!
[[email protected] ~]# mysql -uroot 直接就可以登录了 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1
mysql> use mysql //使用mysql库 mysql> update user set password=password(‘654321‘) where user=‘root‘; //更新表(修改密码) mysql>quit
然后找到/etc/my.cnf配置文件,删除之前的skip-grant命令,保存退出后重启MySQL服务
[[email protected] ~]# /etc/init.d/mysqld restart
[[email protected] ~]# mysql -uroot -p654321 更改密码生效,重新登入 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.73 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
本文出自 “Linux菜鸟” 博客,请务必保留此出处http://490617581.blog.51cto.com/11186315/1758780
以上是关于mysql的root密码重置的主要内容,如果未能解决你的问题,请参考以下文章
Mac - MySQL初始密码忘记重置MySQL root密码