mysql--->安装
源码安装
http://blog.itpub.net/29500582/viewspace-1377052/
二进制安装
#!/bin/sh
#install-mysql.sh
BASEDIR="/usr/local/mysql"
PROGNAME="mysql-5.6.26"
PKGNAME="mysql-5.6.26-linux-glibc2.5-x86_64"
yum install libaio* -y
[ -f ${PKGNAME}".tar.gz" ] || wget http://aliyun-dep.oss-cn-beijing.aliyuncs.com/mysql/${PKGNAME}.tar.gz
mkdir -p ${BASEDIR}/${PROGNAME}
[ -d ${PKGNAME} ] || tar -zxf ${PKGNAME}.tar.gz
mv ./${PKGNAME}/* ${BASEDIR}/${PROGNAME}
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
${BASEDIR}/${PROGNAME}/scripts/mysql_install_db --datadir=${BASEDIR}/${PROGNAME}/data/ --basedir=${BASEDIR}/${PROGNAME} --user=mysql
#!/bin/bash
ifubuntu=$(cat /proc/version | grep ubuntu)
if14=$(cat /etc/issue | grep 14)
if [ `uname -m` == "x86_64" ];then
machine=x86_64
else
machine=i686
fi
if [ $machine == "x86_64" ];then
rm -rf mysql-5.6.26-linux-glibc2.5-x86_64
if [ ! -f mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz ];then
wget http://aliyun-dep.oss-cn-beijing.aliyuncs.com/mysql/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
fi
tar -xzvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.26-linux-glibc2.5-x86_64/* /aliyun/server/mysql
else
rm -rf mysql-5.6.26-linux-glibc2.5-i686
if [ ! -f mysql-5.6.26-linux-glibc2.5-i686.tar.gz ];then
wget http://aliyun-dep.oss-cn-beijing.aliyuncs.com/mysql/mysql-5.6.26-linux-glibc2.5-i686.tar.gz
fi
tar -xzvf mysql-5.6.26-linux-glibc2.5-i686.tar.gz
mv mysql-5.6.26-linux-glibc2.5-i686/* /aliyun/server/mysql
fi
if [ "$ifubuntu" != "" ] && [ "$if14" != "" ];then
mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
fi
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
/aliyun/server/mysql/scripts/mysql_install_db --datadir=/aliyun/server/mysql/data/ --basedir=/aliyun/server/mysql --user=mysql
chown -R mysql:mysql /aliyun/server/mysql/
chown -R mysql:mysql /aliyun/server/mysql/data/
chown -R mysql:mysql /aliyun/log/mysql
\cp -f /aliyun/server/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i 's#^basedir=$#basedir=/aliyun/server/mysql#' /etc/init.d/mysqld
sed -i 's#^datadir=$#datadir=/aliyun/server/mysql/data#' /etc/init.d/mysqld
cat > /etc/my.cnf <<END
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
log-error=/aliyun/log/mysql/error.log
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
expire_logs_days = 5
max_binlog_size = 1000M
END
cp /aliyun/server/mysql/bin/mysql /usr/local/bin/
mkdir -p /aliyun/log/mysql
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start