请教:mysql5.7使用mysqld_exporter监控,报权限问题

IT_YAO 2019-09-09 09:34:51
使用mysqld_exporter对公司的mysql进行监控,报msg="Error pinging mysqld: Error 1045: Access denied for user 'exporter'@'localhost' (using password: YES)" source="mysqld_exporter.go:268"

mysqld_exporter版本mysqld_exporter-0.10.0.linux-amd64
msyql版本5.7.26

操作步骤:
1,root登陆mysql
2, 新建用户并赋权
GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'exporter'@'localhost' identified by '123456';
GRANT SELECT ON *.* TO 'exporter'@'localhost';
flush privileges;
3,创建.my.cnf文件 vi .my.cnf:
[client]
user=exporter
password=123456
4, 执行nohup ./mysqld_exporter -config.my-cnf=.my.cnf &
结果报错msg="Error pinging mysqld: Error 1045: Access denied for user 'exporter'@'localhost' (using password: YES)" source="mysqld_exporter.go:268"

关键是,使用Mysql-5.6.25的版本采取同样的操作就没问题

5.6版本是自己虚拟机的,5.7的是公司的,总不能改版本吧

从报错上看,应该还是权限的问题,试过'exporter'@'%' 不行,试过user=root也不行,都是报同样的错误
是不是mysql5.7有其他的设置?
...全文
2344 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ivan521ILU 2021-09-07
  • 打赏
  • 举报
回复

3,创建.my.cnf文件 vi .my.cnf:
[client]
host=127.0.0.1
user=exporter
password=123456

设置mysql的连接地址 host 。本人在 mysql5.7 测试有效。

ly1022 2019-12-05
  • 打赏
  • 举报
回复 1
我也遇到这个问题了; 我的解决办法 mysqld_exporter连接数据库有两种方式, 1、配置文件.my.cnf 2、环境变量 export DATA_SOURCE_NAME='root:password@tcp(ip:3306)/' 我改成环境变量的方式好了,希望对你有帮助

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧