原文鏈接:https://www.zimrilink.com/devops/295.html
參考鏈接:https://mariadb.com/kb/en/upgrading-from-mariadb-103-to-mariadb-104/
在本教程將指導你如何在CentOS 7上,將MariaDB升級/安裝到最新的Mariadb10.4版本。
本教程也適用於CWP和VestaCP或任何其他兼容的VPS服務器控制面板。
MariaDB的LOGO
MariaDB 10.4現在非常穩定,並且在此版本中添加和改進了許多功能。
你可以在此處檢查所有更改列表。
我們已經使用WordPress、Joomla、xenforo、IPS論壇和一些依賴於MySQL DB的PHP腳本檢查了MariaDB 10.4,因此可以安全地升級到此版本。
MariaDB是什么?
關於MariaDB的簡短描述:
MariaDB被設計為MySQL的直接替代品。
具有更多功能:新存儲引擎,更少的錯誤和更好的性能。
MariaDB由MySQL的許多原始開發人員開發,他們現在為MariaDB Foundation和MariaDB Corporation以及社區中的許多人工作。
要升級,請按照以下簡單步驟,將其升級到最新版本。
步驟1:刪除MariaDB舊版本
刪除MariaDB 5.5 / 10.0 / 10.1 / 10.2 / 10.3
在安裝之前,建議你備份先備份MySQL數據庫。
cp /etc/my.cnf /etc/my.cnf.bak
現在我們需要刪除安裝在centos 7上的當前版本的mariadb 5.5:
對於MariaDB 5.5 ▼
service mariadb stop / service mysql stop
rpm -e --nodeps galera
yum remove mariadb mariadb-server
此時MariaDB 5.5將被完全刪除,但數據庫不會被刪除,不必擔心。
對於MariaDB 10.0 / 10.1 / 10.2 / 10.3 ▼
service mysql stop
rpm -e --nodeps galera
yum remove MariaDB-server MariaDB-client
此時,MariaDB 10.0 / 10.1 / 10.2 / 10.3將被完全刪除,但數據庫不會被刪除,不必擔心。
步驟2:安裝MariaDB 10.4
從MariaDB 5.5 / 10.0 / 10.1 / 10.2 / 10.3版本,安裝/更新到MariaDB 10.4。
安裝/啟用,Mariadb 10.4官方的repo ▼
yum install nano epel-release -y
現在編輯/創建Repo文件/etc/yum.repos.d
如果存在刪除或備份現有的repo文件,請確保你沒有任何其他MariaDB存儲庫文件 ▼
mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb.repo.bak
nano /etc/yum.repos.d/mariadb.repo
然后粘貼以下內容,並保存
國外使用
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
國內使用國內鏡像
[mariadb]
name = MariaDB
baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64/
gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
之后我們將安裝Mariadb 10.4 ▼
yum clean all
yum install MariaDB-server MariaDB-client net-snmp perl-DBD-MySQL -y
yum update -y
恢復my.cnf文件 ▼
cp /etc/my.cnf.bak /etc/my.cnf
然后,激活Mariadb開機啟動,和啟動服務:
systemctl enable mariadb
service mysql start
步驟3:升級當前數據庫
安裝后,我們需要通過以下命令升級當前數據庫 ▼
mysql_upgrade
若無意外,此時你已成功將MariaDB 5.5 / 10.0 / 10.1 / 10.2 / 10.3版本,升級到MariaDB 10.4最新版本了。
如果在輸入命令 mysql_upgrade 升級數據庫時,出現以下錯誤提示 ▼
[root@ ~]# mysql_upgrade
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
FATAL ERROR: Upgrade failed
請使用以下mysql_upgrade 命令來解決
mysql_upgrade -u root --datadir=/var/lib/mysql/ --basedir=/ --password=123456
請將以上“123456”,改成你的MySQL或Mariadb數據庫root密碼。
最后,你可以通過從終端SSH運行此命令,來確認MySQL或Mariadb數據庫版本 ▼
mysql -V
注意事項
如果你的MariaDB數據庫出現類似錯誤提示 ▼
警告:數據庫錯誤 Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 50560, now running 100406. Please use mysql_upgrade to fix this error 查詢 SHOW FUNCTION STATUS
MariaDB數據庫錯誤的解決方法,請點擊以下鏈接查看 ▼
解決警告:數據庫錯誤Column count of mysql.proc is wrong.
使用命令:mysql_upgrade就可以解決