官方文档升级: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/5.5/centos7-amd64/ gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
# 因为官方镜像下载很慢,所以可以替换为国内镜像
3. 停止数据库运行
# systemctl stop mariadb.service
4. 卸载 MariaDB 老版本
# yum remove mariadb mariadb-server
5. 安装新的指定版本mariadb
# sudo yum install MariaDB-server-5.5.64 MariaDB-client-5.5.64
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 mydb mydb.app02_author OK mydb.app02_book OK mydb.app02_book_authors OK mydb.app02_publisher OK mydb.django_migrations OK mysql mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.servers OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK performance_schema test test.authors OK test.book_m2m_author OK test.books OK test.stu_to_tea OK test.students OK test.teachers OK zabbix zabbix.acknowledges OK zabbix.actions OK ... zabbix.widget_field OK Phase 4/4: Running 'mysql_fix_privilege_tables' OK
9. 检查数据库
# mysql -V mysql Ver 15.1 Distrib 5.5.65-MariaDB, for Linux (x86_64) using readline 5.1 #查看版本升级成功 # cd /var/lib/mysql # 查看mysql日志和数据库的数据