需求

对于数据库我们经常使用,使用源码包安装太费时间了,在网络较好的情况下。建议使用yum在线安装MySQL,非常方便!

安装环境

1.CentOS 7 2.关闭防火墙,增强性 3.可连接外网

安装步骤

下载mysql源安装包

yum -y install wget wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm -y

检测源是否安装成功

yum repolist enabled | grep "mysql.-community."

安装mysql服务

yum install mysql-community-server -y

安装版本控制(可选)

vim /etc/yum.repos.d/mysql-community.repo

启动mysql服务

systemctl start mysqld
systemctl status mysqld

设置开机启动

systemctl enable mysqld
systemctl daemon-reload #重载服务

查看密码

grep 'temporary password' /var/log/mysqld.log

重设密码

mysql -uroot -p set password for 'root'@'localhost'=password('Mypass@123#!');

实现远程登录

grant all privileges on *.* to 'root'@'%' identified by 'Mypass@123#!' with grant option; #设置权限 flush privileges;

参考文档

https://blog.csdn.net/kabolee/article/details/82528913