CentOS7安装mysql5.7(yum)

安装环境:CentOS7 64位 ,安装MySQL5.7

1、配置YUM源

在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/

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

安装mysql源

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

检查mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"
image.png

2、安装MySQL

yum install mysql-community-server

3、启动MySQL服务

systemctl start mysqld

4、开机启动

systemctl enable mysqld
systemctl daemon-reload

5、修改root本地登录密码

mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:

set password for 'root'@'localhost'=password('password!'); 
image.png

6、允许远程连接

create user '用户名'@'%' identified by '密码';
grant all privileges on 数据库.* to '用户名'@'%' with grant option;
flush privileges;

你可能感兴趣的:(CentOS7安装mysql5.7(yum))