MySQL-安装mysql8

bluet00 2020-03-28

1. 安装配置

# 解压
tar -xf mysql-8.0.18-el7-x86_64.tar.gz -C /ups/app/mysql/
cd /ups/app/mysql/
mv mysql-8.0.18-el7-x86_64 mysql8

cd mysql8
mkdir -p {config,logs}
mkdir -p /ups/data/mydata/mysql8
chown -R mysql:mysql .
chown -R mysql:mysql /ups/data/mydata/mysql8
chmod 700 /ups/data/mydata/mysql8

cat> config/my.cnf <<-EOF
[mysqld]
basedir                     = /ups/app/mysql/mysql8
datadir                     = /ups/data/mydata/mysql8
log-error                   = /ups/app/mysql/mysql8/logs/mysql6033.err
pid-file                    = /ups/app/mysql/mysql8/logs/mysql6033.pid
socket                      = /ups/app/mysql/mysql8/logs/mysql6033.sock
port                        = 6033
default-storage-engine      = INNODB
character-set-server        = utf8mb4
collation-server            = utf8mb4_general_ci

# connect limits
max_connect_errors          = 5
max_connections             = 1000
max_user_connections        = 100
wait_timeout                = 100

open_files_limit            = 1024

# 限制将系统文件读到数据库(/etc/passwd)
local-infile                = 0

skip_name_resolve           = ON

server_id                   = 6033001

# error log、genera log timestamp
log_timestamps=SYSTEM

# 在关闭是将热数据dump到本地磁盘
innodb_buffer_pool_dump_at_shutdown = 1

# 在启动时将热数据加载到内存
innodb_buffer_pool_load_at_startup = 1
EOF

# 初始化MySQL
/ups/app/mysql/mysql8/bin/mysqld --defaults-file=/ups/app/mysql/mysql8/config/my.cnf --user=mysql --basedir=/ups/app/mysql/mysql8 --datadir=/ups/data/mydata/mysql8 --initialize 

# 启动服务
/ups/app/mysql/mysql8/bin/mysqld_safe --defaults-file=/ups/app/mysql/mysql8/config/my.cnf &

2. 配置账号

# mysql8 默认使用caching_sha2_password算法
# 修改root账号密码
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘root‘;
# 远程登录
create user ‘192.168.10.%‘ IDENTIFIED WITH mysql_native_password BY ‘root‘ ;
grant all privileges on *.* to ‘root‘@‘192.168.10.%‘ with grant option;
flush privileges;

# 检查确认
select host,user, authentication_string, plugin from mysql.user;

相关推荐