当前位置:

首页 > 编程开发 > CentOS7安装MySQL5.6常见问题及解决方法

CentOS7安装MySQL5.6常见问题及解决方法

本文目录

    在一测试服务器(centoslinuxrelease7.2.1511)上安装mysql5.6(5.6.19mysqlcommunityserver)时遇到下面错误,这个是因为centos7的默认数据库已经不再是mysql了,而是mariadb.mysql安装时的mysqllib库与mariadb的库、包冲突了,如下详情所示(省略了大量日志)[root@azrlnx06tmp]#rpm-ivhmysql-server-advanced-5.6.20-1.rhel5.x86_64.rpmpreparing..

    在一测试服务器(centos linux release 7.2.1511)上安装mysql 5.6(5.6.19 mysql community server)时遇到下面错误,这个是因为centos 7的默认数据库已经不再是mysql了,而是mariadb. mysql安装时的mysql lib库与mariadb的库、包冲突了,如下详情所示(省略了大量日志)

    [root@azrlnx06 tmp]# rpm -ivh mysql-server-advanced-5.6.20-1.rhel5.x86_64.rpm 
    preparing... ################################# [100%]
    file /usr/share/mysql/czech/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/danish/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/dutch/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/english/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/estonian/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/french/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/german/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/greek/errmsg.sys from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    ........................................................................................................................................................................
    file /usr/share/mysql/charsets/macroman.xml from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64
    file /usr/share/mysql/charsets/swe7.xml from install of mysql-server-advanced-5.6.20-1.rhel5.x86_64 conflicts with file from package mariadb-libs-1:5.5.50-1.el7_2.x86_64

    检查是否存在mariadb的相关组件,然后删除mariadb相关组件。如下所示:

    [root@azrlnx06 mysql]# more /etc/redhat-release 
    centos linux release 7.2.1511 (core) 
    [root@azrlnx06 mysql]# rpm -qa |grep mariadb
    mariadb-libs-5.5.50-1.el7_2.x86_64
    [root@azrlnx06 mysql]# rpm -e mariadb-libs-5.5.50-1.el7_2.x86_64
    error: failed dependencies:
    libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
    [root@azrlnx06 mysql]# rpm -e mariadb-libs-5.5.50-1.el7_2.x86_64 --nodeps

    当然此处删除mariadb-libs-5.5.50-1.el7_2.x86_64组件时遇到依赖错误,遂强制删除该组件,最好使用yum删除mariadb相关组件。然后重新安装mysql时遇到"error: mysql-server-advanced-5.6.20-1.rhel5.x86_64: install failed"错误,如下所示:

    [root@azrlnx06 mysql]# cd /tmp
    [root@azrlnx06 tmp]# ls
    hsperfdata_azrlnx06 jirasetup mysql-server-advanced-5.6.20-1.rhel5.x86_64.rpm
    [root@azrlnx06 tmp]# rpm -ivh mysql-server-advanced-5.6.20-1.rhel5.x86_64.rpm 
    preparing... ################################# [100%]
    updating / installing...
    1:mysql-server-advanced-5.6.20-1.rh################################# [100%]
    error: unpacking of archive failed on file /usr/bin/innochecksum;582535c8: cpio: read failed - no such file or directory
    error: mysql-server-advanced-5.6.20-1.rhel5.x86_64: install failed
    [root@azrlnx06 tmp]# 
    clip_image001

    对这个错误有点莫名其妙,卸载mysql相关组件后,重新安装mysql,发现缺少perl相关模组。如下所示:

    [root@azrlnx06 jirasetup]# rpm -ivh mysql-server-advanced-5.6.20-1.rhel5.x86_64.rpm 
    preparing... ################################# [100%]
    updating / installing...
    1:mysql-server-advanced-5.6.20-1.rh################################# [100%]
    fatal error: please install the following perl modules before executing /usr/bin/mysql_install_db:
    data::dumper
    [root@azrlnx06 jirasetup]#

    使用yum安装了 perl perl-devel相关包(注意:此处安装mysql时,没有输出安装相关detail的信息,是因为perl相关模组没有安装的缘故,此处还漏掉了安装perl-data-dumper)

    [root@azrlnx06 jirasetup]# yum install -y perl perl-devel

    安装完perl相关组件后,重新安装mysql,如下所示,安装成功,但是没有输出安装相关detail的信息(因为没有安装perl-data-dumper),启动mysql报错

    root@azrlnx06 jirasetup]# rpm -ivh mysql-server-advanced-5.6.20-1.rhel5.x86_64.rpm 
    preparing... ################################# [100%]
    updating / installing...
    1:mysql-server-advanced-5.6.20-1.rh################################# [100%]
    [root@azrlnx06 jirasetup]# rpm -ivh mysql-client-advanced-5.6.20-1.rhel5.x86_64.rpm 
    preparing... ################################# [100%]
    updating / installing...
    1:mysql-client-advanced-5.6.20-1.rh################################# [100%]
    [root@azrlnx06 ~]# service mysql start
    starting mysql............. error! the server quit without updating pid file (/var/lib/mysql/azrlnx06.pid).
    [root@azrlnx06 ~]#

    找到mysql的错误日志,然后检查/var/lib/mysql/azrlnx06.err错误日志,发现如下错误信息:

    [root@azrlnx06 mysql]# find / -name *.err
    /var/lib/mysql/azrlnx06.err
    /var/log/azure/microsoft.ostcextensions.linuxdiagnostic/2.3.9011/mdsd.err
    /var/log/azure/microsoft.ostcextensions.linuxdiagnostic/2.3.9013/mdsd.err
    /var/log/mdsd/mdsd.err
    [root@azrlnx06 mysql]# more /var/lib/mysql/azrlnx06.err
    161111 03:28:25 mysqld_safe starting mysqld daemon with databases from /var/lib/mysql
    2016-11-11 03:28:25 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2016-11-11 03:28:25 2144 [note] plugin 'federated' is disabled.
    /usr/sbin/mysqld: table 'mysql.plugin' doesn't exist
    2016-11-11 03:28:25 2144 [error] can't open the mysql.plugin table. please run mysql_upgrade to create it.
    2016-11-11 03:28:25 2144 [note] innodb: using atomics to ref count buffer pool pages
    2016-11-11 03:28:25 2144 [note] innodb: the innodb memory heap is disabled
    2016-11-11 03:28:25 2144 [note] innodb: mutexes and rw_locks use gcc atomic builtins
    2016-11-11 03:28:25 2144 [note] innodb: memory barrier is not used
    2016-11-11 03:28:25 2144 [note] innodb: compressed tables use zlib 1.2.3
    2016-11-11 03:28:25 2144 [note] innodb: using linux native aio
    2016-11-11 03:28:25 2144 [note] innodb: using cpu crc32 instructions
    2016-11-11 03:28:25 2144 [note] innodb: initializing buffer pool, size = 128.0m
    2016-11-11 03:28:25 2144 [note] innodb: completed initialization of buffer pool
    2016-11-11 03:28:25 2144 [note] innodb: the first specified data file ./ibdata1 did not exist: a new database to be created!
    2016-11-11 03:28:25 2144 [note] innodb: setting file ./ibdata1 size to 12 mb
    2016-11-11 03:28:25 2144 [note] innodb: database physically writes the file full: wait...
    2016-11-11 03:28:26 2144 [note] innodb: setting log file ./ib_logfile101 size to 48 mb
    2016-11-11 03:28:31 2144 [note] innodb: setting log file ./ib_logfile1 size to 48 mb
    2016-11-11 03:28:37 2144 [note] innodb: renaming log file ./ib_logfile101 to ./ib_logfile0
    2016-11-11 03:28:37 2144 [warning] innodb: new log files created, lsn=45781
    2016-11-11 03:28:37 2144 [note] innodb: doublewrite buffer not found: creating new
    2016-11-11 03:28:37 2144 [note] innodb: doublewrite buffer created
    2016-11-11 03:28:37 2144 [note] innodb: 128 rollback segment(s) are active.
    2016-11-11 03:28:37 2144 [warning] innodb: creating foreign key constraint system tables.
    2016-11-11 03:28:37 2144 [note] innodb: foreign key constraint system tables created
    2016-11-11 03:28:37 2144 [note] innodb: creating tablespace and datafile system tables.
    2016-11-11 03:28:38 2144 [note] innodb: tablespace and datafile system tables created.
    2016-11-11 03:28:38 2144 [note] innodb: waiting for purge to start
    2016-11-11 03:28:38 2144 [note] innodb: 5.6.20 started; log sequence number 0
    2016-11-11 03:28:38 2144 [warning] no existing uuid has been found, so we assume that this is the first time that this server has been started. generating a new uuid: ef3b0cd5-a7be-11e6-98b3-000d3a8062fe.
    2016-11-11 03:28:38 2144 [note] rsa private key file not found: /var/lib/mysql//private_key.pem. some authentication plugins will not work.
    2016-11-11 03:28:38 2144 [note] rsa public key file not found: /var/lib/mysql//public_key.pem. some authentication plugins will not work.
    2016-11-11 03:28:38 2144 [note] server hostname (bind-address): '*'; port: 3306
    2016-11-11 03:28:38 2144 [note] ipv6 is available.
    2016-11-11 03:28:38 2144 [note] - '::' resolves to '::';
    2016-11-11 03:28:38 2144 [note] server socket created on ip: '::'.
    2016-11-11 03:28:38 2144 [error] fatal error: can't open and lock privilege tables: table 'mysql.user' doesn't exist
    161111 03:28:38 mysqld_safe mysqld from pid file /var/lib/mysql/azrlnx06.pid ended
    clip_image002

    搜索了一些相关资料,应该是perl-data-dumper模组没有安装,导致安装过程中,初始化数据库失败,所以启动mysql服务时,找不到相关系统表。具体参考官方文档mysql-server rpm does not install perl-data-dumper as a dependency

    description:

    mysql-server requires perl-data-dumper to function. however, perl-data-dumper is not listed by the mysql-server rpm as a dependency. so if a linux server does not have perl-data-dumper installed, the install-mysql-db will fail. and because of missing the initial database, the mysql service could not be started.

    how to repeat:

    on a linux server, make sure there is no perl-data-dumper installed. install mysql-server using yum. there should be error message complaining database could not be created.

    suggested fix:

    add perl-data-dumper as a dependency of the rpm package

    解决方法:

    1:安装perl-data-dumper模组。

    [root@azrlnx06 mysql]# yum install -y perl-data-dumper

    2:初始化数据库

    [root@azrlnx06 mysql]# sudo mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
    clip_image003
    [root@azrlnx06 mysql]# service mysql start
    starting mysql. success! 
    [root@azrlnx06 mysql]# /usr//bin/mysqladmin -u root password 'qwe!23'
    warning: using a password on the command line interface can be insecure.

    当然也可以卸载mysql,然后重新安装,就能看到安装过程输出的detail信息输出了。

    本文内容来源于网友投稿,如有侵权请联系删除。
    作者最新文章
    编程开发 MySQL
    相关文章 更多
    链表删除节点的时间复杂度是多少及其详细分析
    链表删除节点的时间复杂度是多少及其详细分析

    详细分析链表删除节点的时间复杂度,深入探讨单链表与双向链表在不同已知前提下的查找与删除开销,并结合完整代码与清晰图解进行对比总结。

    codex如何配置模型参数及文件设置教程
    codex如何配置模型参数及文件设置教程

    想知道如何让AI写出的代码更贴合你的习惯?本文手把手教你在VS Code中调整Codex相关模型参数,通过修改配置文件优化温度值和令牌限制,解决代码建议不准确或响应慢的问题。

    Claude Code AI编程工具实力揭秘与编程助手实测
    Claude Code AI编程工具实力揭秘与编程助手实测

    通过实测展示Claude Code在终端中如何理解自然语言指令、自动修改代码文件并处理复杂编程任务,帮助开发者评估其实际辅助能力。

    winforms教程自学入门与基础开发步骤详解
    winforms教程自学入门与基础开发步骤详解

    本教程详细讲解如何使用Visual Studio创建WinForms项目,通过添加按钮和标签控件并编写点击事件代码,实现一个基础的计数器功能,适合C#初学者快速上手Windows窗体应用开发。

    Cursor自动补全设置教程教你快速开启代码补全功能
    Cursor自动补全设置教程教你快速开启代码补全功能

    详解Cursor编辑器中自动补全功能的开启与优化设置,涵盖Tab触发机制、上下文窗口调整及模型切换,帮助开发者解决补全延迟、干扰大等问题,提升编码流畅度。

    pandas的数据格式怎么转换和设置方法教程
    pandas的数据格式怎么转换和设置方法教程

    详解Pandas中数据格式转换的核心方法,包括astype强制转换、to_numeric容错处理及日期解析技巧,解决常见类型错误并提升数据处理效率。

    VS Code中文设置方法 简体语言包安装与切换教程
    VS Code中文设置方法 简体语言包安装与切换教程

    详细介绍在Visual Studio Code中安装Chinese (Simplified)语言包的方法,包括通过扩展市场搜索、安装及自动重启切换至简体中文界面的完整步骤,帮助开发者快速将编辑器本地化。

    cursor安装过程无法更改安装位置的解决方法
    cursor安装过程无法更改安装位置的解决方法

    针对Cursor安装包默认锁定C盘且无路径选择界面的问题,提供通过手动移动文件并创建目录联结(Symbolic Link)的解决方案,实现将软件安装在其他磁盘分区。

    rust下载安装教程详解及Windows环境配置方法
    rust下载安装教程详解及Windows环境配置方法

    详解Windows系统下Rust语言的安装步骤,重点解析rustup工具链管理机制,解决环境变量配置错误及MSVC链接器缺失问题,提供可复制的命令验证方法与常见报错的因果排查思路。

    vs code怎么配置 chat实用设置教程步骤
    vs code怎么配置 chat实用设置教程步骤

    详解VS Code中Chat插件的安装与核心配置步骤,重点解决API连接失败、响应慢等常见问题,通过优化上下文设置提升代码生成质量,适合希望集成AI辅助工具的开发者阅读。

    查看更多
    精品专题 更多
    装机必备
    装机必备

    正软商城装机必备专区,精选办公、浏览器、安全防护、影音播放、压缩解压、设计创作和系统工具等电脑常用正版软件,帮助用户快速完成新电脑软件配置。

    Windows
    Windows

    正软商城Windows软件专区,汇集适用于Windows电脑的办公、设计、安全防护、影音播放、开发工具和系统优化软件,提供软件介绍、系统要求、正版授权及购买下载服务。

    macOS软件
    macOS软件

    正软商城macOS软件专区,精选适用于Mac电脑的办公、设计、影音、效率、开发和系统工具,提供软件功能介绍、macOS兼容版本、正版授权及购买下载服务。

    Mac软件 更多
    photoshop
    photoshop
    Windows、macOS 、 iPad

    Photoshop 2026 是 Adobe 推出的专业图像处理与视觉设计软件,支持 Windows、macOS 和 iPad 等平台,广泛应用于摄影修图、电商设计、平面海报、数字绘画及视觉合成等创作场景。

    Blender
    Blender
    Windows、macOS 和 Linux

    Blender 是一款免费开源、跨平台的专业 3D 创作软件,集建模、动画、渲染、视频编辑与视觉合成等功能于一体,广泛应用于影视动画、游戏设计和建筑可视化等领域。软件支持 Cycles 物理渲染器与 Eevee 实时渲染引擎,并提供多边形建模、骨骼绑定、物理模拟等专业工具。Blender 兼容 Windows、macOS 和 Linux 系统,安装包轻巧、运行流畅,依托活跃的全球开发者社区持续更新,是从初学者到专业创作者都值得选择的正版 3D 创作工具。

    灵活计算器
    灵活计算器
    macOS/iOS/Android

    灵活计算器是一款笔记式算数应用,支持实时计算、动态关联和云端同步功能。记录、整理和输出之间的过渡会更自然,适合长期写作、做笔记或持续沉淀个人内容。

    WINDOWS 更多
    3dmax(3ds max)
    3dmax(3ds max)
    Windows

    Autodesk 3ds Max 是一款专业的三维建模、动画与渲染软件,广泛应用于建筑可视化、游戏开发、影视动画、广告设计和产品展示等领域。

    photoshop
    photoshop
    Windows、macOS 、 iPad

    Photoshop 2026 是 Adobe 推出的专业图像处理与视觉设计软件,支持 Windows、macOS 和 iPad 等平台,广泛应用于摄影修图、电商设计、平面海报、数字绘画及视觉合成等创作场景。

    Blender
    Blender
    Windows、macOS 和 Linux

    Blender 是一款免费开源、跨平台的专业 3D 创作软件,集建模、动画、渲染、视频编辑与视觉合成等功能于一体,广泛应用于影视动画、游戏设计和建筑可视化等领域。软件支持 Cycles 物理渲染器与 Eevee 实时渲染引擎,并提供多边形建模、骨骼绑定、物理模拟等专业工具。Blender 兼容 Windows、macOS 和 Linux 系统,安装包轻巧、运行流畅,依托活跃的全球开发者社区持续更新,是从初学者到专业创作者都值得选择的正版 3D 创作工具。