Linux下源码编译安装mariadb数据库
程序员文章站
2022-06-04 12:36:49
...
环境:centos7
准备:mariadb-10.2.18.tar 数据库安装包
[[email protected] ~]# rz
Transferring mariadb-10.2.18.tar.gz...
第一步: 创建mysql用户
[[email protected] ~]# useradd -r -s /sbin/nologin -d /data/myql mysql
第二步:安装编译时需要用到的包
[[email protected] yum.repos.d]#
yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openss-devel libevent-devel libaio-devel
第二步:创建家目录
[[email protected] ~]# mkdir /data/mysql
[[email protected] ~]# chown mysql:mysql /data/mysql/
[[email protected] ~]# ll -d /data/mysql/ ###修改家目录所有者、所属组
drwxr-xr-x 2 mysql mysql 6 Sep 28 20:26 /data/mysql/
第三步:解压缩
[[email protected] ~]# tar xvf mariadb-10.2.18.tar.gz
[[email protected] ~]# cd mariadb-10.2.18/
cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/data/mysql/ \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make -j 4
提示:如果出错,执行rm -f CMakeCache.txt
第四步:生成数据库文件
[[email protected] support-files]# cd /app/mysql/
[[email protected] mysql]# scripts/mysql_install_db --datadir=/data/mysql --user=mysql
第五步:拷贝配置文件
[[email protected] mysql]# cd /app/mysql/support-files
[[email protected] support-files]# cp my-huge.cnf /etc/my.cnf
[[email protected] support-files]# vim /etc/my.cnf
[mysqld]
datadir=/data/mysql ###增加mysql数据库路径
第六步:拷贝启动文件
[[email protected] mysql]# cd /app/mysql/support-files
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
第七步:添加启动列表
chkconfig --add mysql
第八步:修改配置文件中的socker权限目录
[[email protected] support-files]# vim /etc/my.cnf
[client]
socket = /data/mysql/mysql.sock
[mysqld]
datadir=/data/mysql
port = 3306
socket = /data/mysql/mysql.sock
第九步:启动服务
[[email protected] support-files]# service mysqld start
第十步:
[[email protected] support-files]# echo PATH=/app/mysql/bin:$PATH > /etc/profiled.d/mysql.sh
[[email protected] support-files]# . /etc/profile.d/mysql.sh
完成。