官方文档升级:https://mariadb.com/kb/en/library/upgrading/
1.备份原来的数据库和配置文件
# mysqldump -u root -p -A > alldb.sql # cp /etc/my.cnf /etc/my.cnf.bak
2.添加 MariaDB Yum仓库
# vim /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB #baseurl = http://yum.mariadb.org/10.3/centos7-amd64 #gpgkey= https://yum.mariadb.org/RPM-GPG-KEY-MariaDB baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.5/centos7-amd64/ gpgkey= http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1 #上述baseurl 可输入指定的数据库版本进行安装升级
3. 停止数据库运行
# systemctl stop mariadb.service
4. 卸载 MariaDB 老版本
# yum remove mariadb mariadb-server
5. 安装新的指定版本mariadb
# yum install mariadb mariadb-server
6. 修改配置文件my.cnf
7. 启动MariaDB
# systemctl start mysql
8. 运行 mysql_upgrade升级数据库
# mysql_upgrade -uroot -p Enter password: Phase 1/4: Fixing views Phase 2/4: Fixing table and database names Phase 3/4: Checking and upgrading tables Processing databases information_schema ... Phase 4/4: Running 'mysql_fix_privilege_tables'OK