linux mysql离线脚本安装教程,linux上mysql脚本一键安装

说明(适用于8.0以上数据库版本):

1、下载数据库安装包,把对应的tar包和脚本文件放在/root下。

2、使用root用户运行脚本。

3、期间输入mysql密码时,直接敲回车, 如果不小心输入了回车,流程断了,可以输入 /usr/local/mysql/bin/mysql -u root -p -h localhost < /tmp/mysql_sec_script systemctl stop firewalld.service systemctl disable firewalld.service

这三条命令

4、安装后路径/usr/local/mysql/

5、安装后数据库密码为123456(可以修改脚本)

6、设置环境变量 ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

7、如要进行双机热备安装,将主和从的脚本中114行的server-id改为服务器的ip后三位或两位(不重复就好)

8、脚本内容(本人用的数据库版本为“mysql-8.0.12-linux-glibc2.12-x86_64”,如下在不同版本,只需将脚本中的版本改为对应的,不要懒得直接贴过去用,看一下,改一下!!!!) ###### 二进制自动安装数据库脚本root密码ROOT将脚本和安装包放在/root目录即可############### ######数据库目录/usr/local/mysql############ ######数据目录/data/mysql############ ######慢日志目录/data/slowlog############ ######端口号默认3306############ # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to install" exit 1 fi clear echo "=========================================================================" echo "A tool to auto-compile & install MySQL 8.0.12 on Redhat/CentOS Linux " echo "=========================================================================" cur_dir=$(pwd) #which MySQL Version do you want to install? echo "===========================" isinstallmysql812="n" echo "Install MySQL 8.0.12,Please input y" read -p "(Please input y , n):" isinstallmysql812 case "$isinstallmysql812" in y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) echo "You will install MySQL 8.0.12" isinstallmysql812="y" ;; *) echo "INPUT error,You will exit install MySQL 8.0.12" isinstallmysql812="n" exit esac get_char() { SAVEDSTTY=`stty -g` stty -echo stty cbreak #dd if=/dev/tty bs=1 count=1 2> /dev/null stty -raw stty echo stty $SAVEDSTTY } echo "" echo "Press any key to start...or Press Ctrl+c to cancel" char=`get_char` # Initialize the installation related content. function InitInstall() { cat /etc/issue uname -a MemTotal=`free -m | grep Mem | awk '{print $2}'` echo -e "\n Memory is: ${MemTotal} MB " #Set timezone #rm -rf /etc/localtime #ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #Disable SeLinux if [ -s /etc/selinux/config ]; then sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config fi setenforce 0 } #Installation of depend on and optimization options. function InstallDependsAndOpt() { cd $cur_dir cat >>/etc/security/limits.conf<> /etc/sysctl.conf } #Install MySQL function InstallMySQL812() { echo "============================Install MySQL 8.0.12==================================" cd $cur_dir #Backup old my.cnf #rm -f /etc/my.cnf if [ -s /etc/my.cnf ]; then mv /etc/my.cnf /etc/my.cnf.`date +%Y%m%d%H%M%S`.bak fi echo "============================MySQL 8.0.12 installing…………=========================" #mysql directory configuration tar xvf /root/mysql-8.0.12-linux-glibc2.12-x86_64.tar mv /root/mysql-8.0.12-linux-glibc2.12-x86_64 /usr/local/mysql #edit /etc/my.cnf cat >>/etc/my.cnf<>/etc/profile.d/mysql.sh<>/tmp/mysql_sec_script<&1 | tee /root/mysql-install.log InstallDependsAndOpt 2>&1 | tee -a /root/mysql-install.log InstallMySQL812 > /dev/null CheckInstall 2>&1 | tee -a /root/mysql-install.log

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值