Mysql_Binary_Install_Scripts(采用二进制方式安装)
Posted Wolf_Dreams
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql_Binary_Install_Scripts(采用二进制方式安装)相关的知识,希望对你有一定的参考价值。
1.1 mysql实现代码
#!/bin/bash ######################################## #auth:wolf_dreams #time:2018-10-20 #bbs:https://www.cnblogs.com/Wolf-Dreams/ ######################################## Softwarename="mysql-5.6.40-linux-glibc2.12-x86_64" Binarypacket="/services/tools/${Softwarename}.tar.gz" Basedir="/application" if [ -f $Binarypacket ];then mkdir $Basedir; cd / && tar zxvf $Binarypacket -C $Basedir else exit 1 fi if [ $? -eq 0 ];then /bin/mv $Basedir/$Softwarename $Basedir/mysql-5.6.40 else exit 1 fi grep mysql /etc/passwd if [ $? -ne 0 ];then useradd -s /sbin/nologin -M mysql else exit 1 fi if [ -d $Basedir/mysql-5.6.40/ ];then ln -s $Basedir/mysql-5.6.40/ $Basedir/mysql chown -R mysql:mysql $Basedir/mysql else exit 1 fi $Basedir/mysql/scripts/mysql_install_db --user=mysql --basedir=$Basedir/mysql --datadir=$Basedir/mysql/data /bin/cp -p $Basedir/mysql/support-files/my-default.cnf /etc/my.cnf echo "explicit_defaults_for_timestamp=true" >> /etc/my.cnf /bin/cp -p $Basedir/mysql/support-files/mysql.server /etc/init.d/mysqld sed -i "s#/usr/local/mysql#$Basedir/mysql#g" $Basedir/mysql/bin/mysqld_safe /etc/init.d/mysqld if [ $? -eq 0 ];then /etc/init.d/mysqld start chkconfig --list | grep mysqld if [ $? -ne 0 ];then chkconfig --add mysqld chkconfig mysqld on fi else exit 1 fi echo "export PATH=$PATH:$Basedir/mysql/bin" >> /etc/profile source /etc/profile > /dev/null 2>&1 exit 0
1.2 如何运行该脚本呢?
到您需要安装的MYSQL数据库的服务器上新建mysql_install.sh文件,复制以上shell代码,保存退出;使用sh mysql_install.sh运行,耐心等待一会,mysql数据库安装完成。
以上是关于Mysql_Binary_Install_Scripts(采用二进制方式安装)的主要内容,如果未能解决你的问题,请参考以下文章