现象
排查过程
- 进入数据库
- show grants for zabbix@localhost;
- select host,user from mysql.user;
- cat /etc/zabbix/zabbix_server.conf | grep DB | grep -vE ‘#|$’
- cat /etc/zabbix/web/zabbix.conf.php | grep DB
解决办法
- 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;"
- 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;"