mysql 一键安装脚本
[backcolor=inherit]#! /bin/bash[backcolor=inherit]#本脚本用于一键安装mysql,cmake-3.0.1.tar.gz和mysql-5.5.37.tar.gz需要放在同一目录[backcolor=inherit]useradd mysql[backcolor=inherit]tar -zvxf cmake-3.0.1.tar.gz[backcolor=inherit]cd cmake-3.0.1[backcolor=inherit]./configure[backcolor=inherit]make && make install[backcolor=inherit]if [ $? -eq 0 ]; then[backcolor=inherit] cd ..[backcolor=inherit] tar -zvxf mysql-5.5.37.tar.gz[backcolor=inherit] cd mysql-5.5.37[backcolor=inherit] cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DDEFAULT_CHARSET=gbk -DDEFAULT_COLLATION=gbk_chinese_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1[backcolor=inherit] if [ $? -eq 0 ]; then[backcolor=inherit] make && make install[backcolor=inherit] if [ $? -eq 0 ]; then[backcolor=inherit]cd support-files/[backcolor=inherit]cp mysql.server /etc/init.d/mysqld[backcolor=inherit]cp my-medium.cnf /etc/my.cnf[backcolor=inherit]chown -R mysql:mysql /home/test/mysql[backcolor=inherit]/home/test/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/home/test/mysql --datadir=/home/test/mysql/data --user=mysql[backcolor=inherit]chmod +x /etc/init.d/mysqld[backcolor=inherit]sed -i 's/^basedir=/basedir=\/home\/test\/mysql/' /etc/init.d/mysqld[backcolor=inherit]sed -i 's/^datadir=/datadir=\/home\/test\/mysql\/data/' /etc/init.d/mysqld[backcolor=inherit]chkconfig --add mysqld[backcolor=inherit]chkconfig --level 235 mysqld on[backcolor=inherit]service mysqld start[backcolor=inherit]fi[backcolor=inherit] fi[backcolor=inherit] fi
参考链接:http://axlewire.blog.51cto.com/1418858/1607654