首页 > 数据库技术 > 详细

mysql忘记登陆密码

时间:2019-06-20 19:00:41      阅读:94      评论:0      收藏:0      [点我收藏+]

修改mysql的配置文件my.cnf

my.cnf配置文件的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf

在配置文件中,增加2行代码

[mysqld]

skip-grant-tables

然后启动mysql服务,并进入mysql

[root@b ~]# service mysqld start
[root@b ~]#
[root@b ~]# mysql -u root 
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
 
mysql>


 修改密码

连接mysql这个数据库,修改用户密码

mysql> use mysql;
Database changed
mysql> update mysql.user set authentication_string=password(root_password‘) where user=‘root‘;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> \q


使用新密码登陆
[root@b ~]# mysql -u root -p
输入新密码
修改root登陆密码
mysql>
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘xxxxxxxx‘;

mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
mysql> \q


 
 

mysql忘记登陆密码

原文:https://www.cnblogs.com/xiaofeng666/p/11060614.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!