Access denied for user ‘zabbix‘@‘localhost‘ (using password: NO)

文章详细描述了如何在MySQL8.0及以上和低于8.0版本中为Zabbix用户zabbix设置数据库权限,包括创建数据库、用户、分配所有权限以及字符集设置。

现象
在这里插入图片描述

排查过程

  1. 进入数据库
  2. show grants for zabbix@localhost;
  3. select host,user from mysql.user;
  4. cat /etc/zabbix/zabbix_server.conf | grep DB | grep -vE ‘#|$’
  5. cat /etc/zabbix/web/zabbix.conf.php | grep DB

解决办法

  1. mysql 8.0以下
DPassword='123.com'
mariadb -e "create database zabbix character set utf8mb4 collate utf8mb4_bin;"
mariadb -e "grant all privileges on zabbix.* to'zabbix'@'localhost' identified by '$DPassword';"
mariadb -e "grant all privileges on zabbix.* to'zabbix'@'%' identified by '$DPassword';"
mariadb -e "set character_set_server=utf8mb4;"
mariadb -e "flush privileges;"
  1. mysql 8.0以上
DPassword="Root@123456"
mysql -u root -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -e "create user 'zabbix'@'%' identified by '$DPassword';"
mysql -e "create user 'zabbix'@'localhost' identified by '$DPassword';"
mysql -e "grant all privileges on zabbix.* to'zabbix'@'localhost';"
mysql -e "grant all privileges on zabbix.* to'zabbix'@'%';"
mysql -e "ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY '$DPassword';"
mysql -e "ALTER USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY '$DPassword';"
mysql -e "flush privileges;"

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

NoYoWiFi

感谢大佬赐赏

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

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

打赏作者

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

抵扣说明:

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

余额充值