本文主要是介绍MySQL笔记_02_MySQL5.7二进制自动化安装脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
[root@localhost mysql_install]# vim mysql5.7_install.sh
work_dir=/opt/soft/mysql_install
src_file=mysql-5.7.35-linux-*.tar.gz
mysql_base_dir=/usr/local/mysql
mysql_data_dir=/data/mysql
# 卸载mariadb
if [ `rpm -qa | grep mariadb` ]
then
for v in `rpm -qa | grep mariadb`
do
echo ${v}
yum -y remove ${v}
done
fi
# 安装libaio
rpm -q libaio > /dev/null 2>&1 || yum -y install libaio
# 配置用户
id -g mysql > /dev/null 2>&1 && echo "mysql group is exists" || groupadd mysql
id -u mysql > /dev/null 2>&1 && echo "mysql user is exists" || useradd -r -g mysql mysql -s /sbin/nologin
#!/bin/bash
work_dir=/opt/soft/mysql_install
src_file=mysql-5.7.35-linux-*.tar.gz
mysql_base_dir=/usr/local/mysql
mysql_data_dir=/data/mysql
# 卸载mariadb
if [ `rpm -qa | grep mariadb` ]
then
for v in `rpm -qa | grep mariadb`
do
echo ${v}
yum -y remove ${v}
done
fi
# 安装libaio
rpm -q libaio > /dev/null 2>&1 || yum -y install libaio
# 配置用户
id -g mysql > /dev/null 2>&1 && echo "mysql group is exists" || groupadd mysql
id -u mysql > /dev/null 2>&1 && echo "mysql user is exists" || useradd -r -g mysql mysql -s /sbin/nologin
#!/bin/bash
work_dir=/opt/soft/mysql_install
src_file=mysql-5.7.35-linux-*.tar.gz
mysql_base_dir=/usr/local/mysql
mysql_data_dir=/data/mysql
# 卸载mariadb
if [ `rpm -qa | grep mariadb` ]
then
for v in `rpm -qa | grep mariadb`
do
echo ${v}
yum -y remove ${v}
done
fi
# 安装libaio
rpm -q libaio > /dev/null 2>&1 || yum -y install libaio
# 配置用户
id -g mysql > /dev/null 2>&1 && echo "mysql group is exists" || groupadd mysql
id -u mysql > /dev/null 2>&1 && echo "mysql user is exists" || useradd -r -g mysql mysql -s /sbin/nologin
# 解压软件 软链接
tar zxf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz -C /usr/local
ln -s /usr/local/mysql-5.7.35-linux-glibc2.12-x86_64 ${mysql_base_dir}
chown -R mysql:mysql ${mysql_base_dir}
# 创建目录
[ -d ${mysql_data_dir} ] && echo "${mysql_data_dir} is exists" || mkdir -p ${mysql_data_dir}/{data,logs,binlog}
chown -R mysql:mysql ${mysql_data_dir}
# 添加环境变量
echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
source /etc/profile
# 编写配置文件
cat << EOF > /etc/my.cnf
[client]
socket = /data/mysql/my.sock
[mysql]
prompt = (\\\u@\\\h) [\\\d]>\\\_
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/data
port = 3306
socket = /data/mysql/my.sock
log-error = /data/mysql/logs/error.log
EOF
# 初始化数据库
${mysql_base_dir}/bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure
${mysql_base_dir}/bin/mysqld_safe --defaults-file=/etc/my.cnf &
这篇关于MySQL笔记_02_MySQL5.7二进制自动化安装脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!