首页 > 代码库 > mysql安装脚本
mysql安装脚本
#!/bin/bash #description:the Script is used to installing mysql echo " ================================================ + MySQL Install (version 5.1) + ================================================" echo " During installation, you can use "tail -f /root/mysql_install.log " to view MySQL " install_path=/usr/local log=/root/mysql_install.log if [ -e /etc/yum.repos.d/CentOS6-Base-163.repo ] then yum install wget -y &>> $log echo "---the env is ok---" else echo "please check your yum" && exit 1 fi echo "1.---mysql install---" rpm -q mysql-server mysql &>/dev/null [ $? -eq 0 ] && yum remove mysql-server mysql -y &>> $log rpm -q ncurses-devel &> /dev/null [ $? -ne 0 ] && yum install ncurses ncurses-devel -y &>> $log cd /usr/src && wget http://down1.chinaunix.net/distfiles/mysql-5.1.56.tar.gz &>/dev/null [ $? -ne 0 ] && echo " the mysql download is error " && exit 1 || echo " the mysql download is ok " tar zxf mysql-5.1.56.tar.gz cd mysql-5.1.56 ./configure --prefix=/usr/local/mysql-5.1.56 --with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --localstatedir=/usr/local/mysql-5.1.56/data --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-thread-safe-client --with-mysqld-user=mysql --with-big-table --without-debug --with-pthread &>> $log if [ $? -eq 0 ] then echo " the mysql configure is oK" make &>> $log [ $? -ne 0 ] && echo " the mysql make is error" && exit 1 echo " the mysql make is OK" make install &>> $log [ $? -ne 0 ] && echo " the mysql make install is error" && exit 1 echo " the mysql make install is OK" else echo " the mysql configure is error" echo " please cat the $log" sleep 4 exit 1 fi echo " ----------------------mysql config------------" >> $log echo "2.---mysql config---" useradd -M -s /sbin/nologin -u 49 mysql if [ -d support-files ] then rm -f /etc/my.cnf cp -f support-files/my-medium.cnf /etc/my.cnf & echo " the my.cnf build is ok" else echo " no support-file" && exit 1 fi cd $install_path/mysql-5.1.56/bin ./mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.1.56 --datadir=/usr/local/mysql-5.1.56/data &>> $log [ $? -ne 0 ] && echo " the mysql Initialization is error" && exit 1 || echo " the mysql Initialization is OK" chown -R root:mysql $install_path/mysql-5.1.56/ [ -d $install_path/mysql-5.1.56/data ] && chown -R mysql $install_path/mysql-5.1.56/data || echo "no $install_path/mysql-5.1.56/data" ln -s $install_path/mysql-5.1.56/bin/* $install_path/bin ln -s $install_path/mysql-5.1.56/lib/mysql/* /usr/lib ln -s $install_path/mysql-5.1.56/include/mysql/* /usr/include ln -sf /usr/local/mysql-5.1.56/ /usr/local/mysql cp -f /usr/src/mysql-5.1.56/support-files/mysql.server /etc/init.d/mysqld chmod a+x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on echo " the mysql config is oK" sleep 2 service mysqld start &>> $log mysqladmin -uroot password ‘123.com‘ echo " the mysql is start" echo " note: the mysql datadir is ${install_path}/mysql/data " echo "the mysql user is root password is 123.com"
本文出自 “Study-Everyday” 博客,请务必保留此出处http://studys.blog.51cto.com/9736817/1604038
mysql安装脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。