bug宝典之linux root用户看不到mysql数据库了

打开一个ssh

service mysqld stop #关闭mysql
/usr/bin/mysqld_safe --skip-grant-tables & #安全模式

打开另个ssh

mysql -u root -p
use mysql
select * from user where user='root' and host='localhost';#查看到root用户权限都变成N了。

执行下面的语句

update user set  `Select_priv` = 'Y' where user='root' and host='localhost';
update user set  `Insert_priv` = 'Y' where user='root' and host='localhost';
update user set  `Update_priv` = 'Y' where user='root' and host='localhost';
update user set  `Delete_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_priv` = 'Y' where user='root' and host='localhost';
update user set  `Drop_priv` = 'Y' where user='root' and host='localhost';
update user set  `Reload_priv` = 'Y' where user='root' and host='localhost';
update user set  `Shutdown_priv` = 'Y' where user='root' and host='localhost';
update user set  `Process_priv` = 'Y' where user='root' and host='localhost';
update user set  `File_priv` = 'Y' where user='root' and host='localhost';
update user set  `Grant_priv` = 'Y' where user='root' and host='localhost';
update user set  `References_priv` = 'Y' where user='root' and host='localhost';
update user set  `Index_priv` = 'Y' where user='root' and host='localhost';
update user set  `Alter_priv` = 'Y' where user='root' and host='localhost';
update user set  `Show_db_priv` = 'Y' where user='root' and host='localhost';
update user set  `Super_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_tmp_table_priv` = 'Y' where user='root' and host='localhost';
update user set  `Lock_tables_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_tmp_table_priv` = 'Y' where user='root' and host='localhost';
update user set  `Lock_tables_priv` = 'Y' where user='root' and host='localhost';
update user set  `Execute_priv` = 'Y' where user='root' and host='localhost';
update user set  `Repl_slave_priv` = 'Y' where user='root' and host='localhost';
update user set  `Repl_client_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_view_priv` = 'Y' where user='root' and host='localhost';
update user set  `Show_view_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_routine_priv` = 'Y' where user='root' and host='localhost';
update user set  `Alter_routine_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_user_priv` = 'Y' where user='root' and host='localhost';
update user set  `Event_priv` = 'Y' where user='root' and host='localhost';
update user set  `Trigger_priv` = 'Y' where user='root' and host='localhost';
update user set  `Create_tablespace_priv` = 'Y' where user='root' and host='localhost';

然后执行flush privileges;,让权限生效,然后执行命令service mysqld start启动mysql即可

出现这个问题的原因是root用户密码应该严格按照阿里云linux环境mysql rpm安装中修密码更改说明
否则会将root用户的权限搞丢失。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

warrah

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值