全部博文(389)
分类: Mysql/postgreSQL
2014-12-28 19:51:25
MySQL自动安装脚本
#!/bin/bash
#author:frankzou
export PATH=/usr/bin:/usr/sbin/:/sbin:/bin
inst_dir=/usr/local/mysql
if [ -d "${inst_dir}" ] || [ -L "${inst_dir}" ] ; then
echo "Mysql directory exists"
exit
fi
echo "MySQL package is encompressing....."
tar -xvf Percona-Server-5.6.14-rel62.0-483.Linux.x86_64.tar.gz -C /usr/local/ >/dev/null
ln -s /usr/local/Percona-Server-5.6.14-rel62.0-483.Linux.x86_64/ ${inst_dir}
groupadd mysql
useradd -g mysql -s /sbin/nolog mysql
chown -R mysql:mysql ${inst_dir}
echo "[mysqld]" >/etc/my.cnf
echo "basedir=${inst_dir}">>/etc/my.cnf
echo "datadir=${inst_dir}/data">>/etc/my.cnf
echo "max_connections=1000">>/etc/my.cnf
echo "query_cache_size=0">>/etc/my.cnf
echo "query_cache_type=0">>/etc/my.cnf
echo "character_set_server=utf8">>/etc/my.cnf
echo "skip_name_resolve">>/etc/my.cnf
echo "innodb_flush_method=O_DIRECT">>/etc/my.cnf
echo "innodb_file_per_table=1">>/etc/my.cnf
echo "socket=/tmp/mysql.socket">>/etc/my.cnf
echo "[client]" >>/etc/my.cnf
echo "socket=/tmp/mysql.socket">>/etc/my.cnf
cd ${inst_dir}
echo "MySQL database is initialing...."
./scripts/mysql_install_db --user=mysql --datadir=${inst_dir}/data >/dev/null
chown -R mysql:mysql ${inst_dir}
cp ${inst_dir}/support-files/mysql.server /etc/init.d/mysqld
chkconfig --level 235 mysqld on
service mysqld start
service mysqld status | grep -v "not"
if [ $? -eq 0 ] ; then
echo "Please change root password quickly"
else
echo "MySQL can not startup!!!"
fi
mysql二进制解压安装脚本,后续需要更新root密码和修改部分自定义能数.