centos安装mysql5.7

summerinsist 2020-08-21

切换yum源

网易yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里云yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all
yum makecache

安装mysql5.7 yum源

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
     (如果虚拟机安装 可以使用wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm --no-check-certificate)

安装mysql rpm包

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

安装msyql

yum install mysql-server

启动mysql
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
查看默认密码
grep ‘temporary password‘ /var/log/mysqld.log

[ app]# grep ‘temporary password‘ /var/log/mysqld.log
2020-08-18T14:39:59.127422Z 1 [Note] A temporary password is generated for : 2fdiYmMZ/<rW

登录mysql
mysql -u root -p
修改初始root密码
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘‘;

授权其他机器登录

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘‘ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH  PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

开启防火墙:
systemctl status firewalld --查看防火墙状态

firewall-cmd --list-all --查看防火墙开放端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
--zone=public 添加时区
--add-port=8080/tcp 添加端口
--permanent 永久生效

firewall-cmd --reload --加载防火墙新配置文件( 以 root 身份输入以下命令,重新加载防火墙,并不中断用户连接,即不丢失状态信息. )

相关推荐