一、创建用户
useradd -r -s /sbin/nologin mysql
二、下载软件包并解压
wget http://mirrors.neusoft.edu.cn/mariadb//mariadb-10.2.12/source/mariadb-10.2.12.tar.gz
tar xvf mariadb-10.2.12.tar.gz
三、安装所需包组
yum groupinstall "development tools"
yum install cmake
yum install ncurses-devel
yum install gnutls-devel
yum install libevent-devel
yum install libaio-devel
yum install openssl-devel
yum install libxml2-devel
四、建立数据库目录并设置属主属组
mkdir /mysqldb chown -R mysql.mysql /mysqldb
五、编译安装
cd mariadb-10.2.12/
cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/mysqldb/ \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1
make && make install
六、环境变量
echo 'PATH=/app/mysql/bin/:$PATH' > /etc/profile.d/mysql.sh . /etc/profile.d/mysql.sh chmod +x /etc/profile.d/mysql.sh
七、生成数据库
/app/mysql/scripts/mysql_install_db --basedir=/app/mysql --datadir=/mysqldb --user=mysql
八、程序目录权限
chgrp -R mysql /app/mysql/ chmod 775 /app/mysql/
九、配置文件
cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
十、启动脚本
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
十一、启动服务
service mysqld start
十二、测试连接