centOS7 安装mysql

mysql 版本5.7.27

1下载mysql源安装包

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

2.安装mysql源

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

3.检查mysql源是否安装成功

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

4.安装mysql

  yum install mysql-community-server

5.启动mysql

  systemctl start mysqld

6.查看mysql状态

  systemctl status mysqld

7.开机启动

  systemctl enable mysqld

  systemctl daemon-reload

8.获取mysql初始密码

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

9.修改mysql密码

  set password for 'root'@'localhost'=password('password')  

可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示:

centOS7 安装mysql



上一篇:centos7查看开机启动 关闭开机服务 防火墙


下一篇:NOMP矿池搭建