mysql一键安装脚本

#! /bin/bash

#本脚本用于一键安装mysql,cmake-3.0.1.tar.gz和mysql-5.5.37.tar.gz需要放在同一目录

useradd mysql

tar -zvxf cmake-3.0.1.tar.gz

cd cmake-3.0.1

./configure

make && make install

if [ $? -eq 0 ]; then

 cd ..

        tar -zvxf mysql-5.5.37.tar.gz

 cd mysql-5.5.37

 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

  if [ $? -eq 0 ]; then

    make && make install

       if [ $? -eq 0 ]; then

cd support-files/

cp mysql.server /etc/init.d/mysqld

cp my-medium.cnf /etc/my.cnf

chown -R mysql:mysql /home/test/mysql

/home/test/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/home/test/mysql --datadir=/home/test/mysql/data --user=mysql

chmod +x /etc/init.d/mysqld

sed -i 's/^basedir=/basedir=\/home\/test\/mysql/' /etc/init.d/mysqld

sed -i 's/^datadir=/datadir=\/home\/test\/mysql\/data/' /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig --level 235 mysqld on

service mysqld start

fi

  fi

       fi


你可能感兴趣的:(mysql,一键安装)