#!/bin/bash
#Date:2017-04-23
#Author:Allen_Jol
#mariadb_install_v1.0.sh
#Version:mariadb-10.1.22
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==="
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。