mysql5.7安装

发布时间 2023-12-26 19:25:25作者: EJW
#!/bin/bash
##############################################################
# File Name: install_redis.sh
# Version: V1.0
# Author: junwang
# Organization: 
# Created Time : 2021-04-14 17:12:54
# Description:
##############################################################
tools_path=/server/tools
install_path=/web
mkdir -p $tools_path
mkdir -p $install_path
yum install -y  wget net-tools libaio
setenforce 0
# install mysql
install_mysql(){
pmysql=`netstat -lntup|grep mysql|wc -l`
if [  $pmysql -ge 1   ]
then
    echo " MySQL process already exists !!!!"
    exit 1
else
cd $tools_path
wget http://47.105.153.221:33389/data/User/admin/home/caeri/MySQL/mysql-5.7.34/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz && tar -xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.24-linux-glibc2.12-x86_64 $install_path/mysql
groupadd mysql  && useradd -r -g mysql -s /bin/false mysql
chown  -R mysql:mysql $install_path/mysql/
echo '# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir =  '$install_path'/mysql/
datadir =  '$install_path'/mysql/data
port = 3306
# server_id = .....
socket = '$install_path'/mysql/mysql.sock

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
'>/etc/my.cnf
chmod -R 777 $install_path/mysql
cd $install_path/mysql/bin && ./mysqld --initialize-insecure  --user=mysql
cp  $install_path/mysql/support-files/mysql.server /etc/init.d/mysql
/etc/init.d/mysql start
if [ $? -eq  0  ]
then
   chmod -R 755 $install_path/mysql
   echo "########################################### MySQL installed successfully ####################################### \n
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@#+-------------------------------------------------------------------------------+*@@@@@@@@@
@@@@@@@#...................................................................................=@@@@@@@@
@@@@@@@=...........................................----...........----.....................-@@@@@@@@
@@@@@@@=....-#@@@@*....=@@@@#-..................+*#@@@@#*......+*#@@@@#*+.....+@@@#........-@@@@@@@@
@@@@@@@=....-@@@@@@-..-@@@@@@-................-#@@@@@@@@*....-#@@@@@@@@@@#-...=@@@@-.......-@@@@@@@@
@@@@@@@=....+@@@@@@*..*@@@@@@-.+++++...++++-..=@@@@+--+*-...-#@@@@+--=@@@@#...=@@@@-.......-@@@@@@@@
@@@@@@@=....+@@@@@@@--@@@@@@@+.*@@@@+.+@@@@+..=@@@@*+-......*@@@@-....+@@@@=..=@@@@-.......-@@@@@@@@
@@@@@@@=....=@@@@@@@=*@@@@@@@+..#@@@*.*@@@#...-*@@@@@@#=....#@@@#......@@@@*..=@@@@-.......-@@@@@@@@
@@@@@@@=....=@@@*@@@@@@@=#@@@=..+@@@@+@@@@+.....+*@@@@@@#-..#@@@#......@@@@*..=@@@@-.......-@@@@@@@@
@@@@@@@=....*@@@==@@@@@@-*@@@=...*@@@@@@@*.........-=@@@@*..*@@@@+....+@@@@+..=@@@@........-@@@@@@@@
@@@@@@@=....#@@@+-@@@@@=.*@@@*....#@@@@@@-....-*=++-+@@@@=..-@@@@@=--=@@@@*...=@@@@*****=..-@@@@@@@@
@@@@@@@=....#@@@+.*@@@@-.*@@@#....+@@@@@=.....*@@@@@@@@@#....-#@@@@@@@@@@*....=@@@@@@@@@#..-@@@@@@@@
@@@@@@@=....#@@#-.-###=..=@@@*.....#@@@*......+##@@@@#*+.......+*#@@@@@@@##=..+@@@@@@@@@*..-@@@@@@@@
@@@@@@@=........................+=#@@@#-.........----.............--+=#@@@@+...............-@@@@@@@@
@@@@@@@=........................*@@@@*-.................................-++................-@@@@@@@@
@@@@@@@=........................-@#*+......................................................-@@@@@@@@
@@@@@@@@+.................................................................................-*@@@@@@@@
@@@@@@@@@#===============================================================================*@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
"
echo " Please update password:  alter user 'root'@'localhost' identified by '123456';"
else
    echo "########################################### MySQL installed  failed #######################################"
    exit 1
fi
cd $tools_path && rm -rf *
ln -s $install_path/mysql/mysql.sock /tmp/
fi
} 
install_mysql