0
点赞
收藏
分享

微信扫一扫

大数据中的项目数据采集

孟祥忠诗歌 2024-05-01 阅读 14

问题一:远程连接不上mysql,提示Access denied

一、通过下面命令连接不上数据库

mysql -uroot -p
mysql -uroot -h 10.5.122.100 -P 3306 -p

报错信息如下:

二、解决方式
1.检查用户权限:检查 root 用户的权限确保它有连接过去的权限,可以通过从另一个可以连接的服务器登录 MySQL 后,执行以下命令来检查权限:

SELECT host, user FROM mysql.user WHERE user='root';

2.发现 root 用户没有连接的权限,需要给予它相应的权限。您可以通过以下步骤来添加连接权限(例子为本地连接):

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

命令解说:

问题二:远程连接不上mysql,提示caching_sha2_password

一、通过archery等工具连接报错

报错信息如下:

2059,Authentication plugin ‘caching_sha2_password‘ cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so:no such file or directory

原因:
新版本的MySQL新特性导致,导致认证方式有问题
MySQL 8.0版本默认的认证方式是caching_sha2_password,而像MySQL 5.7版本则为mysql_native_password

二、解决方式
方式一:
修改密码的加密方式,对后续的新建用户有效,而前期的老用户默认密码加密方式还是(caching_sha2_password)
找到my.ini文件,在[mysqld]下添加

default_authentication_plugin=mysql_native_password

方式二:

-- 创建新用户rootnew,设所有ip均可登录,密码root
create user rootnew@'%' identified WITH mysql_native_password BY 'root';
-- grant给hyl赋予所有的库和表的权限。
grant all privileges on *.* to rootnew@'%' with grant option;
-- 刷新
flush privileges;

通过新账号登录成功。。。。飘走了

----编写者:梦想的边缘

举报

相关推荐

0 条评论