Change the storage location of zabbix's MariaDB database
# create
Mkdir / company abbreviation / mysql
# stop database service
Systemctl status mariadb.servicesystemctl stop mariadb.service
# move database files to a new storage location
Cp-rp / var/lib/mysql/ / Company abbreviation / mysql/
# modified database configuration file
[root@iZkdZ ~] # cat / etc/ my.cnf [mysqld] datadir=/ acronym / mysqlsocket=/ acronym / mysql/mysql.socklower_case_table_names = Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group # customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid## include all files from the config directory#!includedir / etc/my.cnf.d
# start the database
Systemctl start mariadb.service systemctl status mariadb.service
# New command to log in to the database, you need to specify mysql.sock
Mysql-uzabbix-p123456-S / Company acronym / mysql/mysql.sock
# create a soft link, otherwise the zabbix page cannot be opened
Mkdir / var/lib/mysqlln-s / company abbreviation / mysql/mysql.sock / var/lib/mysql/mysql.sock
Before this step, I renamed the original / var/lib/mysql directory to / var/lib/mysql_ori. So, there will be a command to create / var/lib/mysql. Confirm below that there is no problem with restarting the zabbix server, and the web interface can be opened normally. I just moved the original / var/lib/mysql directory to the / tmp directory, and then to the company's default directory for backup.
# restart zabbix
Systemctl restart zabbix-server.service
Reference:
Http://www.cnblogs.com/seasonsstory/archive/2013/07/24/3209785.html--zabbix cannot connect to the database
Http://blog.chinaunix.net/uid-20749043-id-1878317.html-- change mysql storage path