大数据随记 —— MySQL 只能远程登录,不能本地登录

问题描述

MySQL 只能远程登录,不能本地登录。(这个问题最直观的表现就是这样,还有下面的表现)

本地登不上去

[root@master ~]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

在这里插入图片描述

MySQL 没有权限

mysql> use mysql
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

在这里插入图片描述

mysqld:Shutdown complete

[root@master ~]# mysqld
220811  9:21:48 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

220811  9:21:48 [ERROR] Aborting

220811  9:21:48 [Note] mysqld: Shutdown complete

在这里插入图片描述

mysqld 陷入无限循环

[root@node1 sbin]# mysqld --user=root restart
220811  8:46:42 [Note] Plugin 'FEDERATED' is disabled.
220811  8:46:42  InnoDB: Initializing buffer pool, size = 8.0M
220811  8:46:42  InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
220811  8:46:42  InnoDB: Retrying to lock the first data file

在这里插入图片描述

解决方法

几个小时后突然想起来什么,就用本地的 SQLyog 连了一下 CentOS 的 MySQL,发现可以进入。

查询 mysql 库中的 user 表,发现 localhost 的 UserPassword 为空。
在这里插入图片描述

为其重新分配 UserPassword

mysql> grant all privileges on *.* to root@'localhost' identified by '123456';
mysql> flush privileges;

在这里插入图片描述

可以看到已经分配 UserPassword

本地登录成功!

在这里插入图片描述

结束。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

繁依Fanyi

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

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

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

打赏作者

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

抵扣说明:

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

余额充值