数据库
首页 > 数据库> > yum安装mysql5.7

yum安装mysql5.7

作者:互联网

安装

官网下载仓库文件

点击图标,进入下载仓库界面

在linux下载该仓库

[root@VM_0_7_centos ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

查看md5值,和官方进行对比

[root@VM_0_7_centos ~]# md5sum mysql80-community-release-el7-3.noarch.rpm 
893b55d5d885df5c4d4cf7c4f2f6c153  mysql80-community-release-el7-3.noarch.rpm

安装仓库

[root@VM_0_7_centos ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm 

修改yum配置文件

将安装的repo文件中默认的8.0改为5.7生效

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

清除现有缓存

[root@VM_0_7_centos ~]# yum clean all

生成缓存,后续install时在缓存中搜索,提高速度

[root@VM_0_7_centos ~]# yum makecache 

查看yum仓库关于mysql的所有仓库列表

[root@VM_0_7_centos ~]# yum list | grep mysql-com
mysql-community-client.i686              5.7.27-1.el7                  mysql57-community
mysql-community-client.x86_64            5.7.27-1.el7                  mysql57-community
mysql-community-common.i686              5.7.27-1.el7                  mysql57-community
mysql-community-common.x86_64            5.7.27-1.el7                  mysql57-community
mysql-community-devel.i686               5.7.27-1.el7                  mysql57-community
mysql-community-devel.x86_64             5.7.27-1.el7                  mysql57-community
mysql-community-embedded.i686            5.7.27-1.el7                  mysql57-community
mysql-community-embedded.x86_64          5.7.27-1.el7                  mysql57-community
mysql-community-embedded-compat.i686     5.7.27-1.el7                  mysql57-community
mysql-community-embedded-compat.x86_64   5.7.27-1.el7                  mysql57-community
mysql-community-embedded-devel.i686      5.7.27-1.el7                  mysql57-community
mysql-community-embedded-devel.x86_64    5.7.27-1.el7                  mysql57-community
mysql-community-libs.i686                5.7.27-1.el7                  mysql57-community
mysql-community-libs.x86_64              5.7.27-1.el7                  mysql57-community
mysql-community-libs-compat.i686         5.7.27-1.el7                  mysql57-community
mysql-community-libs-compat.x86_64       5.7.27-1.el7                  mysql57-community
mysql-community-release.noarch           el7-5                         mysql-connectors-community
mysql-community-server.x86_64            5.7.27-1.el7                  mysql57-community
mysql-community-test.x86_64              5.7.27-1.el7                  mysql57-community

安装其中的server版本,依赖会自动安装

[root@VM_0_7_centos ~]# yum -y install mysql-community-server.x86_64

启动

启动
第一次启动会初始化,生成数据库文件

[root@VM_0_7_centos ~]# systemctl start mysqld
[root@VM_0_7_centos ~]# 

设置开机启动

[root@VM_0_7_centos ~]# systemctl enable mysqld
[root@VM_0_7_centos ~]# 

查看默认密码
5.7之后的版本登录mysql是有默认密码的

[root@VM_0_7_centos ~]# grep "password" /var/log/mysqld.log 
2019-09-20T12:35:39.605238Z 1 [Note] A temporary password is generated for root@localhost: 6HbfLn,_cC8a

登录

[root@VM_0_7_centos ~]# mysql -uroot -p'6HbfLn,_cC8a'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

标签:27,5.7,mysql5.7,community,yum,mysql,mysql57,安装,el7
来源: https://www.cnblogs.com/inmeditation/p/11559783.html