mariadb编译安装脚本
#!/bin/bash
#Date:2017-04-23
#Author:Allen_Jol
#mariadb_install_v1.0.sh
#Version:mariadb-10.1.22
创新互联-专业网站定制、快速模板网站建设、高性价比克山网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式克山网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖克山地区。费用合理售后完善,十年实体公司更值得信赖。
MARIADB_VERSION="mariadb-10.1.22.tar.gz"
echo "mariadb版本是:$MARIADB_VERSION"
PATHWAY=/usr/local/src
cd $PATHWAY
echo "====================PREPARE======================"
echo "原来装过的或者自带的MySQL如下:"
rpm -qa | grep mysql
#如果是centos7.2默认安装了mariadb-libs,要先卸载
#rpm -e --nodeps mariadb-libs
sleep 3
#rm -rf /etc/my.cnf
yum -y remove mysql*
ls *.tar.gz | xargs -n1 tar zxvf
sleep 5
yum -y install libevent 'Development Tools' ncurses-devel openssl-devel openssl gcc gcc-c++ cmake make
sleep 3
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
mkdir -p /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql/data
sleep 3
#编译安装开始
echo "==============mariadb install will be start for 3 seconds later========"
sleep 3
if [ ! -f mariadb-10.1.22.tar.gz ]
then
echo "没有$MARIADB_VERSION这个包,请查看!"
sleep 3
exit 1
else
tar -zxvf $MARIADB_VERSION
cd ${MARIADB_VERSION%.tar.gz}
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
fi
sleep 3
echo $?
sleep 3
#-j 2代表用cpu双线程去make,这样速度快。lscpu可以查看cpu(s)是多少。
#make -j $(grep processor /proc/cpuinfo | wc –l)
#-j 参数表示根据 CPU 核数指定编译时的线程数,可以加快编译速度。默认为 1 个线程编译
#一个processor就是一个线程
make -j 4
sleep 1
make install
echo $?
chown -R mysql:mysql /usr/local/mysql/data/
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
sleep 3
\cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
\cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
chkconfig --add mysql
chkconfig mysql on
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
/etc/init.d/mysql start
ps -ef | grep mysql
echo "记得登录数据库更改数据库密码,刷新权限。"
echo "如果不能直接用mysql登录数据库,请手动source /etc/profile一下"
echo "=================Mariadb installed successfully!===Congratulation==="
分享文章:mariadb编译安装脚本
标题来源:http://scyanting.com/article/jcidjj.html