三种方式安装mariadb-10.3.18

安装环境:CentOS Linux release 7.5.1804 (Core) 

一、yum安装

官方网站yum配置方法链接:https://mariadb.com/kb/en/library/yum/

1、配置yum源,安装不同版本需要配置不同源
# vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# yum makecache
# yum install mariadb

2、启动服务
# systemctl enable mariadb
# systemctl start mariadb

 

二、二进制安装

1、官网下载二进制包
mariadb-10.3.18-linux-systemd-x86_64.tar.gz

2、准备工作
# useradd -s /sbin/nologin -M mysql
# cd /usr/local
# tar xf mariadb-10.3.18-linux-x86_64.tar.gz
# ln -sv mariadb-10.3.18-linux-x86_64  mysql
# cd mysql
# chown -R mysql:mysql .
# mkdir /data
# chown -R mysql:mysql /data/

3、初始化数据库
# ./scripts/mysql_install_db --user=mysql --datadir=/data

4、配置启动脚本
# cp ./support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data

5、配置环境变量
# echo 'export PATH=/usr/local/mysql/bin:$PATH' >  /etc/profile.d/mysql.sh
# source /etc/profile.d/mysql.sh

6、修改配置文件
[mysqld]
log_bin=mysql-bin
skip_name_resolve=on

7、启动服务
# chkconfig --add mysqld
# service mysqld start

 

三、编译安装

1、安装依赖包
# yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel

2、准备用户和数据目录
# useradd -r -M -s /sbin/nologin mysql
# mkdir -p /data/mysql
# chown mysql.mysql /data/mysql
# tar xf mariadb-10.3.18.tar.gz

3、编译安装
# cd mariadb-10.3.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=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

# make && make install

4、准备环境变量
# echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
# . /etc/profile.d/mysql.sh

5、生成数据库文件
# cd /app/mysql/
# scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql

6、准备配置文件
# cp /app/mysql/support-files/wsrep.cnf /etc/my.cnf

7、准备启动脚本
# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld

8、启动服务
# chkconfig --add mysqld 
# service mysqld start

 

posted on 2019-10-30 17:50  强叔Linux  阅读(6773)  评论(0编辑  收藏  举报