网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

解决mysql忘了root密码的方法

小编给大家分享一下解决MySQL忘了root密码的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

成都创新互联公司主要从事成都做网站、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务石柱土家族,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108

mysql忘了root密码解决方法:

1、修改配置文件my.cnf,在配置文件[mysqld]下添加skip-grant-tables,重启MySQL服务即可免密码登录

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]

skip-grant-tables

2、用空密码的 root 用户连接到 MySQL,并且更改 root 口令:

[root@localhost mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.0.41-community-log MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';  
 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement


mysql> update user set authentication_string = NULL where user = 'root';
Query OK, 1 row affected (0.00 sec)

上面是先用grant的方式修改root密码,但是由于使用了配置了skip-grant-tables 选项,使用“alter user”命令更改密码失败,直

接更新 user 表的 authentication_string字段后更改密码成功。

3、到my.cnf 中删除skip-grant-tables选项,然后直接用mysql -uroot免密码登录后,在执行如下语句重设密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';

看完了这篇文章,相信你对解决mysql忘了root密码的方法有了一定的了解,想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


名称栏目:解决mysql忘了root密码的方法
分享地址:http://bjjierui.cn/article/igedei.html

其他资讯