您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Linux下MySQL忘记root用户密码

2024/3/25 12:42:22发布19次查看
今天在接收一台mysql服务器的时候发现忘记mysql的root用户的密码,查找资料发了各种文档里面也没有root用户密码,因此需要修改ro
今天在接收一台mysql服务器的时候发现忘记mysql的root用户的密码,查找资料发了各种文档里面也没有root用户密码,因此需要修改root用户密码。
首先确认服务器出于安全的状态,也就是没有人能够任意地连接mysql数据库。因为在重新设置mysql的root密码的期间,mysql数据库完全出于没有密码保护的状态下,,其他的用户也可以任意地登录和修改mysql的信息。最安全的状态是到服务器的console上面操作,并且拔掉网线。
1、修改mysql的登录设置:
在[mysqld]的段中加上的skip-grant-tables
# sed -i '/mysqld/a\skip-grant-tables ' /etc/my.cnf
2、重新启动mysqld
# service mysqld restart
shutting down mysql. success!
starting mysql. success!
3、登录并修改mysql的root密码
# /usr/bin/mysql
welcome to the mysql monitor.  commands end with ; or \g.
your mysql connection id is 1
server version: 5.6.19 source distribution
copyright (c) 2000, 2014, 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.
mysql> use mysql ;
reading table information for completion of table and column names
you can turn off this feature to get a quicker startup with -a
database changed
mysql> update user set password = password ( 'linuxidc' ) where user = 'root' ;
query ok, 3 rows affected (0.01 sec)
rows matched: 3  changed: 3  warnings: 0
mysql> flush privileges ;
query ok, 0 rows affected (0.01 sec)
mysql> quit
bye
4、将mysql的登录设置修改回来
将刚才在[mysqld]的段中加上的skip-grant-tables删除
# sed -i /skip-grant-tables/d /etc/my.cnf
5、重新启动mysqld
# service mysqld restart
shutting down mysql. success!
starting mysql. success!
这个时候,就可以使用root/linuxidc进行登录了
linux下mysql的root密码忘记解决方法 
windows/linux mysql忘记root密码的解决方法
mysql忘记root密码解决方法
mysql 更改root密码
在ubuntu中如何重置mysql服务器的root密码
red hat 下 mysql root密码恢复
本文永久更新链接地址:
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product