Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 升級 MySQL 後報錯 conflicts with file 解決方案:移除舊 libs 衝突包

編輯:關於 Linux

MySQL 版本升級常因舊版 mysql-libs 共享函式庫衝突導致安裝失敗或服務無法啟動。核心解法是以 --nodeps 強制移除舊套件或 yum remove 清理後再安裝新版,並提供 mysql_upgrade 修復系統表的後續步驟。

MySQL 升級衝突錯誤示意圖

錯誤現象

file /usr/lib64/mysql/libmysqlclient.so.16 from install of mysql-community-libs-5.6.x conflicts with file from package mysql-libs-5.0.95-5.el5.x86_64

解決方案一:強制移除衝突套件

# 方法 A: rpm 強制移除 (不檢查相依)
rpm -e --nodeps mysql-libs-5.0.95-5.el5.x86_64

# 方法 B: yum 移除 (會處理相依,較安全)
yum -y remove mysql-libs-5.0.95*

# 之後安裝新版
rpm -ivh mysql-community-server-5.6.x.rpm
# 或
yum install mysql-community-server

解決方案二:升級後執行 mysql_upgrade 修復系統表

mysql_upgrade -u root -p"ROOT_PASSWORD"
# 範例
mysql_upgrade -uroot -p123456

此指令會檢查並修復 mysql 系統資料庫的表結構 (如 mysql.servers、mysql.proc 等),解決「無法建立資料庫/使用者」等相容性問題。

版本選擇建議

  • CentOS 6/7 建議使用 MySQL 5.6 或 5.7 (官方 yum repo 提供)
  • MySQL 5.5 相容性較差,不推薦生產環境
  • MariaDB 作為替代品相容性更好,可直接 yum install mariadb-server

Webmin 使用者注意

Webmin 備份資料庫可能報錯但仍生成 SQL 檔;若發現權限問題,可手動執行 mysql_upgrade 或檢查 mysql.servers 表資料完整性。

Copyright © Windows教程網 All Rights Reserved