这篇文章主要为大家展示了“mysql脚本安装的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“mysql脚本安装的示例分析”这篇文章吧。
脚本安装
#!/bin/bash
echo "-----------------------start install mysql----------------------"
#安装必要的包
yum -y install gcc gcc-c++ ncurses openssl openssl-devel make kernel-devel m4 ncurses-devel libtool*
#创建数据存放文件
mkdir -p /data/dbdata
#检查mysql组及用户是否存储,不存储则创建
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
#下载mysql5.1tar包
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包
tar xzvf mysql-5.1.63.tar.gz
#进入安装目录进行安装
cd mysql-5.1.63
echo "configuring mysql,please wait-----------------"
#进行编译配置prefix为软件安装目录,localstatedir为数据存放目录等
./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
cp /usr/local/mysql/bin/mysql* /usr/bin/
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
以上是“mysql脚本安装的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。