1.1 下载MySQL
# -b 后台下载
# -c 断点续传
wget -b -c https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
1.2 解压mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
1.3 安装MySQL
yum -y install mysql-community-*
二、配置MySQL数据库
2.1 修改配置
vim /etc/my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=256M
innodb_log_file_size=2GB
sql_mode=ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
transaction-isolation=READ-COMMITTED
systemctl start mysqld
systemctl enable mysqld
2.2 查看数据库默认密码
cat /var/log/mysqld.log |grep password
mysql -u root -p
2.3 重置root密码
set global validate_password_policy=0;
set global validate_password_number_count=0;
set global validate_password_special_char_count=0;
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
CREATE USER 'root'@'%' IDENTIFIED BY '密码';
grant all privileges on *.* to root@'%';