linux下搭建mysql的方式很多,网上也详解了很多种搭建方式,有直接yum的、有rpm的、、总之,“坑”是层出不穷,有相关文件依赖性、权限、GPG keys等等。

本人也在今天搭建了一下、是出“坑”了,所以来记录下。

--------------------------------------------------------------------------------

本次的搭建方式是使用rpm的方式进行搭建。

相关rpm包下载地址:https://pan.baidu.com/s/1ADAJ0p48_3fiOtijSd9QUQ 密码:z1zm(版本5.7)


第一步:将该包上传至服务器,进行解压:

tar -xvf mysql-5.7.16-1.el6.x86_64.rpm-bundle.tar

解压之后会出现若干rpm文件:

  mysql-community-client-5.7.16-1.el6.x86_64.rpm

  mysql-community-common-5.7.16-1.el6.x86_64.rpm

  mysql-community-devel-5.7.16-1.el6.x86_64.rpm

  mysql-community-embedded-5.7.16-1.el6.x86_64.rpm

  mysql-community-embedded-devel-5.7.16-1.el6.x86_64.rpm

  mysql-community-libs-5.7.16-1.el6.x86_64.rpm

  mysql-community-libs-compat-5.7.16-1.el6.x86_64.rpm

  mysql-community-server-5.7.16-1.el6.x86_64.rpm

  mysql-community-test-5.7.16-1.el6.x86_64.rpm

第二步:使用rpm -ivh xxxxx命令进行安装(切记:顺序要保证同步、各个文件安装之间存在依赖性)

  

  1、rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm、出现如下内容:

  

warning: mysql-community-common-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/french/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/german/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/greek/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/italian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/japanese/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/korean/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/polish/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/romanian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/russian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/serbian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/slovak/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/spanish/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/armscii8.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/ascii.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp1250.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp1256.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp1257.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp850.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp852.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/cp866.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/dec8.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/geostd8.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/greek.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/hebrew.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/hp8.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/koi8r.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/koi8u.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/latin1.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/latin2.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/latin5.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/latin7.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/macce.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/macroman.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.16-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64

  ok,第一行是有点端倪出来了,不过第一步安装算是完成。、

  

  2、rpm -ivh mysql-community-libs-*.rpm

  这一步、我就遇到坑了,先看下报错原因。 

warning: mysql-community-libs-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.16-1.el6.x86_64

  警告行说的报错原因很明显:由于yum安装了旧版本的GPG keys造成的

  还有文件依赖性的原因。(都是同一个版本因此确定版本不会错,只能是前者)

  解决方案:命令后边加上  --force --nodeps  看下成功日志。

Preparing...                ########################################### [100%]
1:mysql-community-libs ########################################### [ 50%]
2:mysql-community-libs-co########################################### [100%]
You have mail in /var/spool/mail/root

  3、rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm  

Preparing...                ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) = 5.7.16-1.el6 is needed by mysql-community-server-5.7.16-1.el6.x86_64

  4、rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm(这一步、也发生了第二步的原因,加上 --force --nodeps  即可,具体报错原因具体对待)  

Preparing...                ########################################### [100%]
1:mysql-community-server ^[^A###### ( 15########################################### [100%]

  ok、到这一步,就完成linux下mysql的安装了(rpm方式)。

启动mysql服务:  

  service mysqld start

查询随机初始root密码:  

  cat /var/log/mysqld.log | grep "temporary password"

登录即可:  

  mysql -uroot -p

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16 Copyright (c) 2000, 2016, 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>

  环境坑、安装坑、包坑、各种坑,踩到了才是学到了。

  

  

  

  

  

linux环境下搭建MySQL的更多相关文章

  1. Linux环境下搭建MYSQL数据库指令详情

    一.mysql数据库的安装 确保安装gcc(开发工具) #groupadd mysql #useradd -g mysql mysql #cd /usr/local # tar -zxvf mysql ...

  2. ​Linux环境下搭建禅道管理工具-包含软件资源

    ​Linux环境下搭建禅道管理工具 1:百度云盘下载: 禅道--链接: https://pan.baidu.com/s/1Stu7nOZVIPO5TnpJWjWtiQ 提取码:dnik CentOs操 ...

  3. 在Linux 环境下搭建 JDK 和 Tomcat

      在Linux 环境下搭建 JDK 和 Tomcat 参考地址:http://www.cnblogs.com/liulinghua90/p/4661424.html   [JDK安装] 1.首先下载 ...

  4. Linux环境下搭建Tomcat+mysql+jdk

    Linux环境 1.下载并安装一个VMware workstation, 这个是虚拟机的平台(自行度娘下载~),虚拟机是在后面要在里面搭建Linux系统. 2.下载一个centos安装包,linux版 ...

  5. 在Linux环境下搭建Tomcat+mysql+jdk环境

    按照下面的步骤一步一步来搭建tomcat+jdk+mysql环境.   [Linux环境]------我搭建的是64位centos版本的linux系统 1.下载并安装一个VMware workstat ...

  6. linux环境下搭建环境发布web项目

    在公司真是学习了一下项目环境在linux下搭建和发布的过程,这是每个程序员都应该掌握的一个技能,将整理下为以后温习用,也乐于和为掌握这些技能的猿分享: 这里主要分为5部分:1.安装jdk,并配置环境变 ...

  7. Windows和Linux环境下搭建SVN服务器

    --------------------------Windows下搭建SVN服务器----------------------------- 一.安装SVN服务端 软件包Setup-Subversi ...

  8. Linux环境下搭建禅道

    如何在Linux下搭建禅道 查看Linux版本信息 # cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 禅道官网下载Linux ...

  9. Linux环境下安装MySQL数据库

    Linux安装mysql服务分两种安装方法: (1).源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: (2).使用官方编译好的二进制文件安装,优 ...

随机推荐

  1. UNIX发展史(BSD,GNU,linux)(转)

    转自 UNIX发展史(BSD,GNU,linux) 这篇文章写的非常好,在这里转一下. 先前的一個理想 UNIX 系统自 1969 年 Ken ThompsonKen Thompson 与 Denni ...

  2. ASP.NET后台怎么输出方法中间调试信息?

    后台方法,不止是aspx.cs,而是页面调用的一些其它方法.想调试这些方法,我以前winform都是MessageBox.Show一些中间结果,现在我也想用这种方式.但想想,网页会触发 Message ...

  3. [置顶] JVM层对jar包字节码加密

    github https://github.com/sea-boat/ByteCodeEncrypt 需求 拿到的需求是要对某特定的jar包实现加密保护,jar包需要提供给外部使用,但核心逻辑部分需要 ...

  4. MacDown语法

    markdown编辑器太多,作为新手比较容易MacDown 相对容易上手,切使用简单方便,满足一般需求 下载地址:http://macdown.uranusjr.com/ ## 标题 # 一级标题 # ...

  5. Eclipse远程调试Java程序

    1. 在服务器上运行jar包时加入参数 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address= 2. 在Eclipse中操作 ...

  6. java中守护线程的一些概念和用法

    网上的资料中,守护线程的功能一般都是“只要当前JVM实例中尚存任何一个非守护线程没有结束,守护线程就全部工作:只有当最后一个非守护线程结束是,守护线程随着JVM一同结束工作,Daemon作用是为其他线 ...

  7. Uoj 22 外星人

    Uoj 22 外星人 注意到一个数只有 \(\%\) 了小于等于自己的数时,才可能有变化,否则可以随意安排,不会对最后最优解造成影响. 用 \(f[x]\) 表示给一个数 \(x\) ,仅用 \(a[ ...

  8. 生成代码,从 T1 到 T16 —— 自动生成多个类型的泛型

    当你想写一个泛型 的类型的时候,是否想过两个泛型参数.三个泛型参数.四个泛型参数或更多泛型参数的版本如何编写呢?是一个个编写?类小还好,类大了就杯具! 事实上,在 Visual Studio 中生成代 ...

  9. 使 32 位程序使用大于 2GB 的内存

    不管在 32 位 Windows 上还是在 64 位 Windows 上,32 位的应用程序都只能使用最大 2GB 的内存,这是我们司空见惯的一个设定.但其实 Windows 提供了一些方法让我们打破 ...

  10. 《DSP using MATLAB》示例Example 9.7

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...