centos7二进制安装mysql8.0.16

#!/bin/bash
# How to install mysql8.0 on centos7 using generic binaries
# https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
# https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-deployment-post-install.html

#MySQL has a dependency on the libaio library
yum install libaio -y
#Obtain and Unpack the Distribution
mkdir -p /root/{jiankong_log,sh,software} && mkdir -p /data/3306 
cd /root/software/
wget -c https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
# wget -c http://miyo.app/yunwei/mysql/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
tar xvf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
cd /usr/local/
mv mysql-8* mysql
#Create a mysql User and Group
groupadd mysql
useradd -r -g mysql -c "MySQL Server" -d "/data/3306" -s /bin/false mysql
#Creating a Safe Directory For Import and Export Operations
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files

#Initializing the Data Directory
bin/mysqld --defaults-file=/etc/3306.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306 
#Starting the Server using systemd
cd /usr/lib/systemd/system
cat > 3306.service << EOF
[Unit]
Description=MySQL Server(3306)
After=network.target,syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

Type=notify

# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0

# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/3306.cnf 

# Sets open_files_limit
LimitNOFILE=65530
LimitNPROC=65530

Restart=on-failure

RestartPreventExitStatus=1

PrivateTmp=false
EOF
systemctl daemon-reload
systemctl start 3306

安装xtrabackup

rpm -ivh percona-xtrabackup-80-8.0.4-1.el7.x86_64.rpm

日志切割

备份脚本

password from /data/3306/error.log

echo 'alter user 'root'@'localhost' identified by 'aaa111222';'
echo 'CREATE USER 'root'@'%' IDENTIFIED BY 'aaa111222';'
echo 'grant all privileges on *.* to root@'%' WITH GRANT OPTION;'

配置文件参考

# The MySQL server
#  by glq 

 [mysqld]

 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
 log_timestamps=system
 default_authentication_plugin=mysql_native_password
 explicit_defaults_for_timestamp
 port                    = 3306
 mysqlx_port             = 33060
 user                    = mysql
 datadir                 = /data/3306
 basedir                 = /usr/local/mysql
 socket                  = /data/3306/mysql.sock
 mysqlx_socket           = /data/3306/mysqlx.sock
 max_connect_errors      = 99999999
 slow_query_log          = 1
 long_query_time         = 0.5
 slow_query_log_file     = /data/3306/slow.log

 init-connect='SET NAMES utf8mb4'
 character-set-server=utf8mb4
 collation-server = utf8mb4_general_ci
 skip-character-set-client-handshake
 bind-address=0.0.0.0

 skip-external-locking
 log-slave-updates
 skip-name-resolve
 skip-slave-start

 server-id               = 3306
 log-bin                 = mysql-bin
 relay-log               = mysql-relay-bin
 log-error=error.log

 #-------------    innodb  --------------
 default-storage-engine          = InnoDB
 innodb_buffer_pool_size         = 256M
 innodb_flush_log_at_trx_commit  = 1
 sync_binlog = 1
 innodb_flush_method = O_DIRECT


 [client]
 user                    = mysql
 port                    = 3306
 socket                  = /data/3306/mysql.sock

 [myisamchk]
 key_buffer = 400M
 sort_buffer_size = 400M
 read_buffer = 256M
 write_buffer = 256M

 [mysqldump]
 quick
 quote-names
 max_allowed_packet             = 128M

 

转载于:https://my.oschina.net/longquan/blog/3049419

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值