文档章节

CentOS 7.2使用yum安装MYSQL 5.7.10

vshcxl
 vshcxl
发布于 2017/01/16 15:42
字数 1851
阅读 61
收藏 1

前面两篇文章《2015博客升级记(四):CentOS 7.1编译安装MySQL5.7.7rc》《阿里云CentOS 7.1使用yum安装MySql5.6.24》分别使用源码编译和YUM方法安装MySQL数据库,这篇文章同样是使用YUM方法在CentOS7.2(64bits)的机器上安装最新的MySQL5.7.10数据库。

1 查看Linux发行版本

[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2 下载MySQL官方的Yum Repository

根据Linux发行版本(CentOS、Fedora都属于红帽系),从mysql官方(http://dev.mysql.com/downloads/repo/yum/)获取Yum Repository。

[root@typecodes ~]#  wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
--2016-02-03 18:36:02--  http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following]
--2016-02-03 18:36:04--  http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25
Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8984 (8.8K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-7.noarch.rpm’

100%[=============================================================================================================================>] 8,984       --.-K/s   in 0s

2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm’ saved [8984/8984]

3 安装MySQL的Yum Repository

安装完MySQL的Yum Repository,每次执行yum update都会检查MySQL是否更新。

[root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpm
Loaded plugins: axelget, fastestmirror, langpacks
Examining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarch
Marking mysql57-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                       Arch                       Version                    Repository                                                   Size
=======================================================================================================================================================================
Installing:
 mysql57-community-release                     noarch                     el7-7                      /mysql57-community-release-el7-7.noarch                     7.8 k

Transaction Summary
=======================================================================================================================================================================
Install  1 Package

Total size: 7.8 k
Installed size: 7.8 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql57-community-release-el7-7.noarch                                                                                                              1/1 
  Verifying  : mysql57-community-release-el7-7.noarch                                                                                                              1/1

Installed:
  mysql57-community-release.noarch 0:el7-7

Complete!

3 安装MySQL数据库的服务器版本

[root@typecodes ~]# yum -y install mysql-community-server
Loaded plugins: axelget, fastestmirror, langpacks
No metadata available for base
No metadata available for epel
No metadata available for extras
repomd.xml                                                                                                                                      | 2.5 kB  00:00:00     
update mysql-connectors-community metadata successfully
repomd.xml                                                                                                                                      | 2.5 kB  00:00:00     
update mysql-tools-community metadata successfully
repomd.xml                                                                                                                                      | 2.5 kB  00:00:00     
update mysql57-community metadata successfully
No metadata available for updates
mysql-connectors-community                                                                                                                      | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                           | 2.5 kB  00:00:00     
mysql57-community                                                                                                                               | 2.5 kB  00:00:00     
(1/3): mysql-tools-community/x86_64/primary_db                                                                                                  |  24 kB  00:00:01     
(2/3): mysql57-community/x86_64/primary_db                                                                                                      |  28 kB  00:00:01     
(3/3): mysql-connectors-community/x86_64/primary_db                                                                                             | 8.6 kB  00:00:02     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.neusoft.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                            Arch                          Version                               Repository                                Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs                               x86_64                        5.7.10-1.el7                          mysql57-community                        2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs-compat                        x86_64                        5.7.10-1.el7                          mysql57-community                        2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server                             x86_64                        5.7.10-1.el7                          mysql57-community                        142 M
Installing for dependencies:
 mysql-community-client                             x86_64                        5.7.10-1.el7                          mysql57-community                         24 M
 mysql-community-common                             x86_64                        5.7.10-1.el7                          mysql57-community                        269 k

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

Total download size: 171 M
Downloading packages:
mysql-community-server-5.7.10-1.el7.x86_64.rpm                                                                                                  | 142 MB  00:03:42     
mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm                                                                                             | 2.0 MB  00:00:03     
mysql-community-libs-5.7.10-1.el7.x86_64.rpm                                                                                                    | 2.2 MB  00:00:05     
mysql-community-client-5.7.10-1.el7.x86_64.rpm                                                                                                  |  24 MB  00:00:41     
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA 
Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
mysql-community-common-5.7.10-1.el7.x86_64.rpm                                                                                                  | 269 kB  00:00:01     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.7.10-1.el7.x86_64                                                                                                          1/6 
  Installing : mysql-community-libs-5.7.10-1.el7.x86_64                                                                                                            2/6 
  Installing : mysql-community-client-5.7.10-1.el7.x86_64                                                                                                          3/6 
  Installing : mysql-community-server-5.7.10-1.el7.x86_64                                                                                                          4/6 
  Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64                                                                                                     5/6 
  Erasing    : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                           6/6 
  Verifying  : mysql-community-server-5.7.10-1.el7.x86_64                                                                                                          1/6 
  Verifying  : mysql-community-libs-compat-5.7.10-1.el7.x86_64                                                                                                     2/6 
  Verifying  : mysql-community-common-5.7.10-1.el7.x86_64                                                                                                          3/6 
  Verifying  : mysql-community-libs-5.7.10-1.el7.x86_64                                                                                                            4/6 
  Verifying  : mysql-community-client-5.7.10-1.el7.x86_64                                                                                                          5/6 
  Verifying  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                           6/6

Installed:
  mysql-community-libs.x86_64 0:5.7.10-1.el7          mysql-community-libs-compat.x86_64 0:5.7.10-1.el7          mysql-community-server.x86_64 0:5.7.10-1.el7

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.10-1.el7                                       mysql-community-common.x86_64 0:5.7.10-1.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.44-2.el7.centos

Complete!
[root@typecodes ~]# clear

最后的截图:

yum安装mysql5.7.10

4 启动数据库:

[root@typecodes ~]# systemctl start  mysqld.service

然后使用命令systemctl status mysql.service查看MySQL数据库启动后的服务状态:

systemctl命令查看MySQL服务状态

5 获取初始密码

使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码:

#######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh
[root@typecodes ~]# grep "password" /var/log/mysqld.log
2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password'
2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password'
2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'

6 修改root用户密码

使用小节5中获取的root用户的初始密码,然后进行修改:

[root@typecodes ~]# mysql -uroot -p
Enter password:             #######输入默认的root密码后回车
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10

Copyright (c) 2000, 2015, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

7 安装完毕

至此,使用在CentOS7中使用YUM方法安装MySQL5.7.10数据库完毕。如下所示,可以使用新的root密码登陆MySQL了。

[root@typecodes ~]# mysql -uroot -ppassword
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.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

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

mysql> clear
mysql> exit
Bye
[root@typecodes ~]# clear

附录1:查看MySQL数据库的配置信息

MySQL的配置文件依然是/etc/my.cnf,其它安装信息可以通过mysql_config命令查看。其中,动态库文件存放在/usr/lib64/mysql目录下。

mysql_config命令查看mysql数据库的安装信息

附录2:对于C/C++等开发者

由于需要用到类似mysql.h等头文件,需要执行下面的命令安装mysql开发版本即可。

[root@typecodes ~]# yum -y install mysql-community-devel

附录3:删除MySQL的Repository

因为小节3中安装了MySQL的Yum Repository,所以以后每次执行yum操作时,都会去检查更新。如果想要去掉这种自动检查操作的话,可以使用如下命令卸载MySQL的Repository即可。

[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch

 

本文转载自:https://typecodes.com/linux/yuminstallmysql5710.html

vshcxl
粉丝 27
博文 282
码字总数 34755
作品 0
浦东
高级程序员
私信 提问
安装最新Mysql community server 5.7.10社区版的坑爹经历

北京时间昨晚(2015-12-07)22点左右,mysql开发团队发布了最新的5.7.10版本,正好我这里也需要安装mysql,于是开始动作。 我的系统环境是centos7,64位系统,所以在http://dev.mysql.com/do...

gaolu
2015/12/08
714
0
MySQL 5.6 VS 5.7压测报告

MySQL 5.6 VS 5.7压测报告 测试条件 1. 软件 OS: CentOS release 6.7 (Final) 文件格式:xfs MySQL:percona5.6.24 VS 5.7.10 关键参数配置(yum install后初始化默认,未做修改): bufferpo...

浮生凤年
2016/04/05
0
0
CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7

CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7 使用 Netkiller OSCM 一键安装PHP环境 Mr. Neo Chen (陈景峯), netkiller, BG7NYT 中国广东省深圳市龙华新区民治街道溪山美地 518131 +86 131...

neo-chen
2018/01/12
74
0
centos6.5安装mysql5.7

本文详细介绍如何CentOS6.5上安装目前最新的mysql(mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz),并搭建mysql服务器 工具/原料 VisualBox安装的CentOS6.5虚拟机 MySQL官网下载的mysql-5.7.1...

xiaoxin
2018/06/12
20
0
centos升级mysql至5.7

CentOS 6.5/6.6 安装mysql 5.7 最完整版教程 defcon 2015年08月04日 发布 推荐 0 推荐 收藏 3 收藏,2.8k 浏览 Step1: 检测系统是否自带安装mysql #yum list installed | grep mysql Step2:...

IT_小翼
2016/01/27
768
0

没有更多内容

加载失败,请刷新页面

加载更多

006-Docker中导出单个或多个tar包

docker中导出单个镜像和多个镜像的tar包 docker save [images] > [name.tar] docker save [images] [images] > [name.tar]...

伟大源于勇敢的开始
今天
8
0
Kotlin基础语法学习

安装好安卓studio,以及插件支持Kotlin 就可以在创建项目的时候选择 Kotlin语言了。 https://www.jianshu.com/p/4ab13691d681 参考手册: https://www.runoob.com/kotlin/otlin-android-setu...

T型人才追梦者
今天
6
0
java实现简单计算器

1.概述 之前作者写过一篇文章,也是关于计算器的,用的是C++与Qt,链接在这里 这次用java的swing写的(这差距好像有点大,好吧是qt太强了). 先上图: 2.UI 总体布局使用流布局. (1)文本框 文本框就...

Blueeeeeee
今天
9
0
纯CSS实现DIV悬浮(固定位置)

纯CSS实现的DIV悬浮效果(固定位置),兼容常用的浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗等。效果如下: 实现代码: <!DOCTYPE html> <html> <head> <meta ...

独钓渔
今天
6
0
OSChina 周二乱弹 —— 给我来个女菩萨

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @这次装个文艺青年吧 :#今日歌曲推荐#分享XXXTENTACION/Travis Barker的单曲《Pain = BESTFRIEND》: 《Pain = BESTFRIEND》- XXXTENTACION/...

小小编辑
今天
119
4

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部