CentOS 7 安裝MySQL 5.6遇到的疑難雜症小結

来源:http://www.cnblogs.com/kerrycode/archive/2016/11/11/6054228.html
-Advertisement-
Play Games

在一測試伺服器(CentOS Linux release 7.2.1511)上安裝MySQL 5.6(5.6.19 MySQL Community Server)時遇到下麵錯誤,這個是因為CentOS 7的預設資料庫已經不再是MySQL了,而是MariaDB. MySQL安裝時的mysql lib庫... ...


在一測試伺服器(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'
 
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 大家都知道如果手機只有一個活動的應用,那這個應用也太簡單了吧。如同網頁一下,是有多個組成的,在C#中我們可以使用各程skip控制項或代碼,這裡不再贅述。 ...
  • 一、TCP/IP協議(傳輸層協議) 1、Socket與ServerSocket Socket是應用層與TCP/IP協議簇通訊的中間抽象層,Socket是一組介面,在設計模式中,Socket的設計就是門面模式,它把複雜的TCP/IP協議簇的內容隱藏在套接字介面後面,用戶無需關心協議的實現,只需使用So ...
  • 場景【1】多表聯查時,主表與關聯表同時與同一張(第三張表)有關聯,類似三角戀關係- - 涉及表: HOUSE:記錄了房屋信息 ROOMS:記錄了房間信息 HOUSE_STATUS:記錄了狀態信息的中文欄位 房屋信息HOUSE表中有一個關於記錄房屋狀態的欄位,status_id,與HOUSE_STAT ...
  • info 伺服器基本信息 monitor 實時轉儲收到的請求 flushdb 清空當前資料庫 flushall 清空所有資料庫 quit 關閉連接 save 將數據同步保持到磁碟 bgsave 非同步 lastsave 返回最後一次成功保存數據到磁碟的時間戳 shundown 將數據同步保持到磁碟並關 ...
  • AND 和 OR 運算符用於基於一個以上的條件對記錄進行過濾。 AND 和 OR 運算符用於基於一個以上的條件對記錄進行過濾。 AND 和 OR 運算符 AND 和 OR 可在 WHERE 子語句中把兩個或多個條件結合起來。 如果第一個條件和第二個條件都成立,則 AND 運算符顯示一條記錄。 如果第 ...
  • 在SQL Server中,為Partition Scheme多次指定Next Used,不會出錯,最後一次指定的FileGroup是Partition Scheme的Next Used,建議,在執行Partition Split操作之前,都要為Partition Scheme指定Next Used。 ...
  • Kafka簡介 轉載請註明出處: "http://www.cnblogs.com/BYRans/" Apache Kafka發源於LinkedIn,於2011年成為Apache的孵化項目,隨後於2012年成為Apache的主要項目之一。Kafka使用Scala和Java進行編寫。Apache Kaf ...
  • 在關係型 DB中,分區表經常使用DateKey(int 數據類型)作為Partition Column,每個月的數據填充到同一個Partition中,由於在Fore-End呈現的報表大多數是基於Month的查詢,按照Month分區的設計能夠提高查詢性能,但是,如果,前任DBA沒有創建Schedule ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...