Centos 7 mysql5.7 yum安装配置

一、下载安装rpm

  1. 进入官方网址点击 MySQL Community Edition DOWNLOAD
  2. Download MySQL Yum Repository(通过yum安装)
  3. 找到对应的Linux系统下载yum

wget  https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

二、安装mysql yum源

1、安装mysql yum

 yum localinstall /opt/mysql80-community-release-el7-1.noarch.rpm

2、修改要安装的版本

# Enable to use MySQL 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

3、检查一下现在的mysql yum配置

[root@iZbp1fkgp9zwe32kb9wft6Z yum.repos.d]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community                  63
mysql-tools-community/x86_64      MySQL Tools Community                       69
mysql57-community/x86_64          MySQL 5.7 Community Server                 287

 

三、安装mysql

[root@iZbp1fkgp9zwe32kb9wft6Z yum.repos.d]# yum install mysql-community-server
......


 Package                                        Arch                      Version                              Repository                            Size
==========================================================================================================================================================
Installing:
 mysql-community-libs                           x86_64                    5.7.23-1.el7                         mysql57-community                    2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-libs-compat                    x86_64                    5.7.23-1.el7                         mysql57-community                    2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-server                         x86_64                    5.7.23-1.el7                         mysql57-community                    165 M
Installing for dependencies:
 libaio                                         x86_64                    0.3.109-13.el7                       base                                  24 k
 mysql-community-client                         x86_64                    5.7.23-1.el7                         mysql57-community                     24 M
 mysql-community-common                         x86_64                    5.7.23-1.el7                         mysql57-community                    274 k

Transaction Summary
==========================================================================================================================================================
Install  3 Packages (+3 Dependent packages)

Total download size: 194 M
Is this ok [y/d/N]: y

四、启动服务

1、启动服务

2、查看root用户密码

3、登陆,输入密码

[root@iZbp1fkgp9zwe32kb9wft6Z yum.repos.d]# systemctl start mysqld
[root@iZbp1fkgp9zwe32kb9wft6Z yum.repos.d]# grep 'temporary password' /var/log/mysqld.log 
2018-08-13T01:19:05.655823Z 1 [Note] A temporary password is generated for root@localhost: exgl3Iffg>qk
[root@iZbp1fkgp9zwe32kb9wft6Z yum.repos.d]# mysql -uroot -p
Enter password: 

五、修改默认密码

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'Pass%word1_';
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值