centos7 mysql5.7安装

Posted koiiok

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 mysql5.7安装相关的知识,希望对你有一定的参考价值。

1.下载yum repo

[root@hadoop002 ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.repo安装

[root@hadoop002 ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm

3.修改yum源默认安装版本

[root@hadoop002 ~]# yum repolist all| grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community        启用:    153
mysql-connectors-community-source MySQL Connectors Community - Sour 禁用
mysql-tools-community/x86_64      MySQL Tools Community             启用:    110
mysql-tools-community-source      MySQL Tools Community - Source    禁用
mysql-tools-preview/x86_64        MySQL Tools Preview               禁用
mysql-tools-preview-source        MySQL Tools Preview - Source      禁用
mysql55-community/x86_64          MySQL 5.5 Community Server        禁用
mysql55-community-source          MySQL 5.5 Community Server - Sour 禁用
mysql56-community/x86_64          MySQL 5.6 Community Server        禁用
mysql56-community-source          MySQL 5.6 Community Server - Sour 禁用
mysql57-community/x86_64          MySQL 5.7 Community Server        启用:    424
mysql57-community-source          MySQL 5.7 Community Server - Sour 禁用
mysql80-community/x86_64          MySQL 8.0 Community Server        禁用
mysql80-community-source          MySQL 8.0 Community Server - Sour 禁用
[root@hadoop002 ~]# vim /etc/yum.repos.d/mysql-community.repo
# 如需修改启动的版本,则修改enabled   1为启用 0位禁用
[root@hadoop002 ~]# yum install -y mysql-community-server

4.启动mysql服务并设置成开机启动

[root@hadoop002 ~]# systemctl start mysqld
[root@hadoop002 ~]# systemctl enable mysqld

5.查看初始密码并修改

[root@hadoop002 ~]# grep \'password\' /var/log/mysqld.log
2020-05-27T15:18:23.821599Z 1 [Note] A temporary password is generated for root@localhost: 54O>pi!0lYc*
[root@hadoop002 ~]# mysql -u root -p
mysql> ALTER USER \'root\'@\'localhost\' IDENTIFIED BY \'KoiioK12#\';

6.设置远程访问

mysql> GRANT ALL PRIVILEGES ON *.* TO \'root\'@\'%\' IDENTIFIED BY \'KoiioK12#\' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

7.使用workbench连接

如果出现连不上,看看防火墙有没有关闭

systemctl status firewalld 
systemctl stop firewalld
systemctl disable firewalld

以上是关于centos7 mysql5.7安装的主要内容,如果未能解决你的问题,请参考以下文章

MySql之centos7.2安装mysql5.7.13

centos7.2安装mysql5.7.13及ssl主从复制

centos7安装mysql5.7步骤(图解版)

centos7安装mysql5.7步骤(图解版)

CentOS7安装MYSQL5.7

CentOS7安装MySQL5.7操作说明