一、使用源代码编译和安装MySQL(mariadb-10.2.12.tar.gz)
tar xf mariadb-10.2.12.tar.gz
yum install libaio-devel bison bison-devel zlib-devel openssl-devel ncurses-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake libevent-devel
mkdir /data
useradd –r –s /bin/false –m –d /data/mysqldb/ mysql
cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/data/mysqldb/ \
-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=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make -j 4 && make install
二、运行MySQL服务
echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
cd /app/mysql/
scripts/mysql_install_db --datadir=/data/mysqldb/ --user=mysql --basedir=/app/mysql
cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld ;service mysqld start