Zabbix mysql 错误解决方案

最后更新于:2023-04-14 11:15:18

  1. 关闭防火墙和selinuxsystemctl stop firewalldsystemctl disable firewalldsetenforce 0 # 设置临时关闭selinuxsed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config #设置永久关闭selinuxreboot #重启
  2. 安装 zabbix rpm 源,鉴于国内网络情况,使用阿里云 zabbix 源rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpmsed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repoyum clean all
  3. 安装 zabbix server 和 agentyum install zabbix-server-mysql zabbix-agent -y

安装Zabbix前端
yum install centos-release-scl
1
编辑配置文件/etc/yum.repos.d/zabbix.repo,使zabbix-frontend 仓库生效。

[zabbix-frontend]

enabled=1

1
2
3
4
安装Zabbix前端软件包

yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

CentOS 7

yum -y install wget
wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
sudo yum install mysql-server --nogpgcheck
systemctl start mysqld && systemctl status mysqld
systemctl enable mysqld
mysql -uroot -p

空密码,直接回车
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
quiit

my.cnf的路径通常是/etc/my.cnf,不过也有人说是在/usr/my.cnfsql

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
...
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables   # 添加这一行
复制代码

第1.找不到初始密码可以在my.ini中[mysqld] 添加:
skip-grant-tables
第2.修改MySQL数据库配置文件无密码登录后,修改密码报错:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

第3.先执行:
flush privileges;
4.再执行修改密码命令,可以了:
set password for root@localhost=password(‘你的密码’);

//创建初始数据库

mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

//导入初始架构和数据,系统将提示您输入新创建的密码

Zabbix 5.0版本
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
password
Zabbix 5.4版本
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix
password

//配置 zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf

DBPassword=password

systemctl restart zabbix-server zabbix-agent nginx rh-php72-php-fpm