tar zvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /opt
mv /opt/mysql-5.7.25-linux-glibc2.12-x86_64 /opt/mysql-5.7.25
5. 配置MySQL环境变量
tee -a /etc/profile <<-'EOF'# wlf-2020-09-21export PATH=$PATH:/opt/mysql-5.7.25/bin
EOF
source /etc/profile
6. 检查系统是否有mysql组和mysql用户
cat /etc/group |grep mysql
#类似
mysql:x:490:
cat /etc/passwd |grep mysql
#类似
mysql:x:496:490::/home/mysql:/bin/bash
以上为存在的情况,如无,执行添加命令:
groupadd mysql
useradd -r -g mysql mysql
#useradd -r参数表示mysql用户是系统用户,不可用于登录系统
7. 创建data目录
mkdir /opt/mysql-5.7.25/data
8. 修改MySQL目录属主属组
chown -R mysql.mysql /opt/mysql-5.7.25
9. 创建默认配置文件
cd /opt/mysql-5.7.25/support-files
vim my_default.cnf
添加如下内容
# 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]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir = /opt/mysql-5.7.25
datadir = /opt/mysql-5.7.25/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
log-error = /opt/mysql-5.7.25/data/mysqld.log
pid-file = /opt/mysql-5.7.25/data/mysqld.pid