四、安装并配置mysql(1) 解压mysql-5.7.26.tar.gz与boost_1_59_0.tar.gz
#tar -xvf mysql-5.7.26.tar.gz
#tar -xvf boost_1_59_0.tar.gz -C /mnt/hg/
(2) 安装依赖包
#yum install -y cmake gcc gcc-c++ openssl-devel ncurses-devel
(3) 编译安装
#cd mysql-5.7.26
#cmake
-DCMAKE_INSTALL_PREFIX=/mnt/hg/mysql-5.7.26
-DMYSQL_DATADIR=/mnt/hg/mysql/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_unicode_ci
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_DEBUG=0
-DWITH_BOOST=/mnt/hg/boost_1_59_0
#make -j4 && make install
(4) 创建所需要的文件及文件夹
#mkdir -pv /mnt/hg/mysql-last/log
#touch /mnt/hg/mysql-last/log/mariadb.log
#touch /mnt/hg/mysql-last/log/mariadb.pid
(5) 更改mysql-5.7.26文件夹的拥有者和拥有组
#cd /mnt/hg && chown mysql:mysql -R mysql-5.7.26
(6) mysql初始化操作① 编辑/etc/my.cnf,跳过mysql登录认证
vim /etc/my.cnf
[mysqld]
datadir=/mnt/hg/mysql-last/data #数据存储的地方
socket=/mnt/hg/mysql-last/mysql.sock #sock文件的路径
skip-grant-tables #跳过登录认证
user=mysql
explicit_defaults_for_timestamp=true
[mysqld_safe]
log-error=/mnt/hg/mysql-last/log/mariadb.log #错误日志存放的地方
pid-file=/mnt/hg/mysql-last/log/mariadb.pid
② 添加mysql命令至PATH变量中
vim /etc/profile
####mysql path
export PATH=$PATH:/mnt/hg/mysql-last/support-files
export PATH=$PATH:/mnt/hg/mysql-last/bin
重新加载环境变量
#source /etc/profile
③ 初始化及启动mysql
#mysqld --initialize --user=mysql --basedir=/mnt/hg/mysql-last --datadir=/mnt/hg/mysql-last/data
#mysql.server start
#ln -s /mnt/hg/mysql-last/mysql.sock /tmp/
④ 导入zabbix初始库
#tar -xvf zabbix-4.2.1.tar.gz
#cd zabbix-4.2.1/database/mysql/
#mysql -u root -p
在mysql里执行:
>use mysql;
>create database zabbix default character set utf8;
>update user set authentication_string = password('hg'), password_expired = 'N', password_last_changed = now() where user = 'root';
>use zabbix;
>source schema.sql;
>source images.sql;
>source data.sql;
>quit;
⑤ 恢复需要密码登录mysql
vim /etc/my.cnf
去掉skip-grant-tables
重新启动mysql
#mysql.server restart
添加lib文件
#echo "/mnt/hg/mysql-last/lib" > /etc/ld.so.conf.d/mysql.conf
#ldconfig -v
本技术资料由广州九一乐维信息科技有限公司提供
作者:胡剑祺
转载请标明出处
延伸阅读
【专注】Zabbix源码安装教程—步骤详解(1)安装前准备
【专注】Zabbix源码安装教程—步骤详解(3)安装并配置nginx
【专注】Zabbix源码安装教程—步骤详解(4)安装并配置php
【专注】Zabbix源码安装教程—步骤详解(5)安装配置Zabbix