MYSQL 5.1自动安装脚本
因为经常会涉及到部署mysql到各个环境(正式、性能、测试等),因此将安装步骤写成shell脚本,减少重复的工作
下面是一个自动化安装mysql 5.1.63的脚本,贴上来,大家可以下载my.cnf文件解压后和脚本放统一目录下,执行安装脚本就可以了。
做一下备忘,脚本内容如下:
my.cnf的压缩附件如下:
my.rar
下面是一个自动化安装mysql 5.1.63的脚本,贴上来,大家可以下载my.cnf文件解压后和脚本放统一目录下,执行安装脚本就可以了。
做一下备忘,脚本内容如下:
点击(此处)折叠或打开
- #!/bin/bash
- echo "-----------------------start install mysql----------------------"
- yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel libtool*
- mkdir -p /data/dbdata
- if [ `grep "mysql" /etc/passwd | wc -l` -eq 0 ];then
- echo "adding user mysql"
- /usr/sbin/groupadd mysql
- /usr/sbin/useradd -g mysql mysql
- else
- echo "mysql user is exist"
- fi
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz- echo "tar xzvf mysql-5.1.63.tar.gz"
- tar xzvf mysql-5.1.63.tar.gz
- cd mysql-5.1.63
- echo "configuring mysql,please wait-----------------"
- ./configure '--prefix=/usr/local/mysql' '--localstatedir=/data/dbdata/' '--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock' '--with-charset=utf8' '--with-extra-charsets=complex' '--with-pthread' '--enable-thread-safe-client' '--with-ssl' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--with-plugins=partition,federated,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive' '--enable-shared' '--enable-assembler'
- if [ $? -ne 0 ];then
- echo "configure filed ,please check it out!"
- exit 1
- fi
- echo "make mysql, please wait for 20 minutes"
- make
- if [ $? -ne 0 ];then
- echo "make filed ,please check it out!"
- exit 1
- fi
- make install
- chown -R mysql:mysql /usr/local/mysql
- chown -R mysql.mysql /data/dbdata/
- /usr/local/mysql/bin/mysql_install_db --user=mysql
- cp ../my.cnf /etc/my.cnf
- cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
- chkconfig --add mysqld
- chkconfig --level 2345 mysqld on
- echo "mysql starting"
- /etc/rc.d/init.d/mysqld start
- if [ $? -ne 0 ];then
- echo "mysql start filed ,please check it out!"
- else
- echo "mysql start successful,congratulations!"
- fi
my.cnf的压缩附件如下:
![](/blog/image/attachicons/rar.gif)