caller=exporter.go:152 level=error msg=“Error pinging mysqld“ err=“Error 1045 (28000): Access denied

ts=2024-05-31T02:32:17.047Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:32:32.046Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:32:47.045Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:33:02.046Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:33:17.048Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:33:32.045Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"
ts=2024-05-31T02:33:47.045Z caller=exporter.go:152 level=error msg="Error pinging mysqld" err="Error 1045 (28000): Access denied for user 'mysql_monitor'@'172.17.0.5' (using password: YES)"

报错背景:

docker + Prometheus + mysqld-exporter

docker运行 mysqld-exporter 报错

问题分析:

账号密码都正确,但是连不上。看到 @‘172.17.0.5’,想到创建mysql用户的时候,使用的是 localhost,只能本机使用mysql_monitor 访问 mysql,而容器运行的时候 mysql_monitor 的地址是 ‘172.17.0.5’,所以连接不上

解决方案:

1.创建容器可以访问的用户

mysql> CREATE USER 'mysql_monitor'@'172.17.%' IDENTIFIED BY 'aaaaaa';
Query OK, 0 rows affected (0.01 sec)

mysql> grant select,replication client,process on *.* to 'mysql_monitor'@'172.17.%';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

2.重新运行容器

运行成功

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值