讲mysql数据包放到/usr/local下
1下载依赖包
yum install -y libaio-devel
在任意目录下创建mysql.sh并授权
chmod u+x mysql.sh
#!/bin/bash
echo '2.屏蔽当前的MySQL环境'
pid=`netstat -lntup|grep 3306|awk -F "[ ]+|/" '{print$7}'`
kill -9 $pid
rm -rf /etc/my.cnf
rm -rf /usr/local/mysql
echo '3.检查并卸载系统中低版本的mysql'
rpm -e mariadb-libs --nodeps
echo '4.添加用户和组'
rm -rf /home/mysql/
userdel mysql
#groupdel mysql
groupadd mysql
useradd -g mysql mysql
echo '5.创建目录及授权'
rm -rf /data/*
mkdir -p /data/mysql/data
mkdir -p /data/binlog
mkdir -p /data/backup
chown -R mysql. /data/
chown -R mysql. /data/mysql/data
chown -R mysql. /data/binlog
chown -R mysql. /data/backup
echo '6.上传解包软件包'
cd /usr/local/
[ -d "mysql-5.7.26-linux-glibc2.12-x86_64" ] || tar zxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz && echo 'file exists!'
mv mysql-5.7.26-linux-glibc2.12-x86_64 mysql
chown -R mysql. /usr/local/mysql
echo '7.修改系统环境变量'
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
source /etc/profile
echo '8.安装mysql依赖'
cd /yl
rpm -ivh --force *.rpm
echo '9.初始化数据'
cd
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
echo '10.生成配置文件'
cd /etc/
touch my.cnf
echo -e '
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
log-error=/var/log/mysql.log
log_bin=/data/binlog/mysql-bin
binlog_format=row
skip-name-resolve
server-id=52
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
relay_log_purge=0
max_connections=1024
back_log=128
wait_timeout=60
interactive_timeout=7200
key_buffer_size=16M
query_cache_size=64M
query_cache_type=1
query_cache_limit=50M
max_connect_errors=20
sort_buffer_size=2M
max_allowed_packet=32M
join_buffer_size=2M
thread_cache_size=200
innodb_buffer_pool_size=1024M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_log_files_in_group=3
binlog_cache_size=2M
max_binlog_cache_size=8M
max_binlog_size=512M
expire_logs_days=7
read_buffer_size=2M
read_rnd_buffer_size=2M
bulk_insert_buffer_size=8M
[client]
socket=/tmp/mysql.sock
' >/etc/my.cnf
echo '11.生成启动方式'
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start