1.系统安装

  • 系统更新及常用软件安装
yum update -y
yum install wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y vim net-tools nmon htop rsync iptraf-ng tree lrzsz ntp iftop telnet tcpdump traceroute
  • 环境配置
echo "0 8 * * * root ntpdate ntp.volphi.com" >> /etc/crontab
sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config
sed -i 's@GSSAPIAuthentication yes@GSSAPIAuthentication no@' /etc/ssh/sshd_config
sed -i 's@#UseDNS yes@UseDNS no@' /etc/ssh/sshd_config
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=3306/tcp
firewall-cmd --add-port=33060/tcp --permanent
firewall-cmd --add-port=33060/tcp

2.mysql8.0安装

  • 上传mysql80-community-release-el7-7.noarch.rpm到服务器
yum install mysql80-community-release-el7-7.noarch.rpm
yum -y install yum-utils
yum install mysql-community-server-8.0.28

3.mysql8.0配置

[mysqld]
# utf8默认库
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci

# 数据最大的连接数
max_connections =1000
binlog_format=mixed

# 设定非交互式断开连接的时间30秒
wait_timeout=30
# 设定交互式断开连接的时间30秒
interactive_timeout = 30

# mysql数据的ID
server-id=1144301

# master db
binlog-ignore-db = mysql,information_schema,performance_schema,sys
auto-increment-increment = 2
auto-increment-offset = 1
# slave db
replicate-ignore-db = mysql,information_schema,performance_schema,sys
log-slave-updates = ON

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

4.用户创建和密码修改

grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
  • mysql中操作
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
create user 'admin@'%' identified by '123456';
grant all privileges on *.* to  'admin'@'%';

create user 'sync'@'%' identified by '123456';
grant all privileges on *.* to  'sync'@'%';
ALTER USER 'sync'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;