mysql安装脚本

#!/bin/bash

创新互联是创新、创意、研发型一体的综合型网站建设公司,自成立以来公司不断探索创新,始终坚持为客户提供满意周到的服务,在本地打下了良好的口碑,在过去的十余年时间我们累计服务了上千家以及全国政企客户,如成都广告推广等企业单位,完善的项目管理流程,严格把控项目进度与质量监控加上过硬的技术实力获得客户的一致表扬。

echo "############################# MySQL installing..........########################"

echo "-----config my.cnf-----"
mv /etc/my.cnf /etc/my.cnf_date +%Y%m%d
SERVER_ID=ifconfig eth0 |grep inet |awk '{print $2}'|awk -F. '{print $3$4}'
Mem=free -m |grep Mem |awk '{print $2}'
SIZE=$[Mem*1/2]
mysqldir=pwd
cat >>/etc/my$ipaddr.cnf<

[mysqld]
user=mysql
server-id = 1
port = 3306
basedir=${mysqldir}/mysql
datadir=${mysqldir}/mysql/mysql_data
tmpdir = /tmp
skip-external-locking
skip_name_resolve = 1
lower_case_table_names = 1
max_connections = 8000
max_connect_errors = 8000
explicit_defaults_for_timestamp = 1
max_allowed_packet = 256M
interactive_timeout = 1800
wait_timeout = 1800
tmp_table_size = 128M
max_heap_table_size = 128M
query_cache_size = 0
query_cache_type = 0
read_buffer_size = 1M
read_rnd_buffer_size = 2M
binlog_cache_size = 8M
join_buffer_size = 128M
back_log = 600
explicit_defaults_for_timestamp = false
query_cache_wlock_invalidate = OFF
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#######log set#############
log_error = ${mysqldir}/mysql/log/mysql.log
slow_query_log = 1
slow_query_log_file = ${mysqldir}/mysql/log/slow.log
log_queries_not_using_indexes = 1
long_query_time = 2
expire_logs_days = 7
log-bin=${mysqldir}/mysql/log/mysql-bin
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

EOF

echo "-----create group and user:mysql-----"
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

echo "----- install dependent package -----"
yum -y install numactl libaio lrzsz wget

#echo "-----Download MySQL-----"
#if [ -d /soft ];then

echo "software dir is exist! Please check!"

#else

mkdir -p /soft

#fi

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar

echo "-----Unzip MySQL-----"
tar -zxvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
mv mysql-5.7.28-1.el7.x86_64.rpm-bundle mysql

echo "-----create datadir and change owner of dir-----"
mkdir -p mysql/mysql_data
mkdir -p mysql/log
chown -R mysql.mysql /etc/my.cnf
chown -R mysql.mysql ${mysqldir}/mysql/
chown -R mysql.mysql ${mysqldir}/mysql/mysql_data/

echo "-----config profile-----"
echo 'PATH=${mysqldir}/mysql/bin/:$PATH' >> /etc/profile
source /etc/profile

echo "-----initialize MySQL-----"
${mysqldir}/mysql/bin/mysqld --initialize --user=mysql --basedir=${mysqldir}/mysql --datadir=${mysqldir}/mysql/mysql_data/

echo "-----start MySQL-----"
cp ${mysqldir}/mysql/support-files/mysql.server /etc/init.d/mysqld
ln -s ${mysqldir}/mysql/bin/mysql /usr/sbin/mysql
/etc/init.d/mysqld start
#${mysqldir}/mysql/bin/mysqladmin -u root password 'passw0rd'
#echo "-----init password of MySQL-----"
OLD_PWD=cat ${mysqldir}/mysql/log/mysql.log | grep "password is generated" |awk '{print $NF}'
${mysqldir}/mysql/bin/mysqladmin -u root -p${OLD_PWD} password 'admin@admin'
echo "root password is: admin@admin"


当前标题:mysql安装脚本
标题来源:http://bzwzjz.com/article/jhddds.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站设计制作 app网站建设 成都网站建设公司 四川成都网站制作 成都网站制作 成都网站建设公司 企业网站设计 网站建设 成都网站设计 成都网站设计公司 定制级高端网站建设 网站设计 网站制作 手机网站制作 企业网站建设 成都网站建设公司 网站建设方案 网站制作报价 成都响应式网站建设 成都网站制作 定制网站建设 成都营销网站建设