#!/bin/bash
# @Name:install_mysql.sh
# @Author:Eivllom
# @Create time:--
# @Modify time:-- app_soft="/app/soft" #软件包存放目录 if [ `ls "${app_soft}" |wc -l` -le ];then
echo '软件包可能还没上传到${app_soft}目录,请检查后再执行脚本!';
exit
fi echo "正在安装cmake"
(
cd ${app_soft}
tar zxf cmake-2.8..tar.gz
cd cmake-2.8.
./configure --prefix=/usr/local/cmake
make && make install
) &> /dev/null && echo 'cmake安装完成' || exit export PATH=/usr/local/cmake/bin:$PATH
echo "正在安装mysql"
(
yum -y install ncurses-devel
groupadd mysql
useradd -s /sbin/nologin -g mysql mysql
cd ${app_soft}
tar zxf mysql-5.6..tar.gz
cd mysql-5.6.
cmake \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/app/mysql/data \
-DMYSQL_UNIX_ADDR=/app/mysql/data/mysql.sock \
-DENABLED_LOCAL_INFILE= \
-DWITH_INNOBASE_STORAGE_ENGINE= \
-DWITH_ARCHIVE_STORAGE_ENGINE= \
-DWITH_BLACKHOLE_STORAGE_ENGINE= \
-DWITH_FEDERATED_STORAGE_ENGINE= \
-DWITH_EXAMPLE_STORAGE_ENGINE= \
-DWITH_PARTITION_STORAGE_ENGINE= \
-DWITH_MYISAM_STORAGE_ENGINE= \
-DWITH_PERFSCHEMA_STORAGE_ENGINE= \
-DMYSQL_TCP_PORT= \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=
make && make install
chown -R mysql.mysql /app/mysql
cd /app/mysql/scripts
./mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data
cd ..
cd support-files/
cp mysql.server /etc/rc.d/init.d/mysql
cp my-default.cnf /etc/my.cnf
chkconfig --add mysql
chkconfig mysql on
/etc/init.d/mysql start
ln -s /app/mysql/bin/* /usr/bin/
) &> /dev/null && echo 'mysql安装完成' || exit