How to upgrade MariaDB 10.x on Linux

สร้างโดย Pattapong Y., แก้ไขเมื่อ Tue, 30 May 2023 เมื่อ 03:18 PM โดย Pattapong Y.

By default, CentOS 7 is shipped with MariaDB 5.5. MariaDB 10.x version is a drop-in replacement for MySQL 5.5-5.7.

Automatic method

Note: The script below is applicable only for upgrading default MariaDB 5.5 to the MariaDB 10.5 version, for other cases apply the steps from the Manual Method section. Make sure Obsidian 18.0.30 or later is installed on the server.

  1. Download the attached script and provide it with executable rights:

    wget && chmod +x

  2. Execute the script via CLI:


Manual Method

  1. For security reasons, create a database dump of all databases with the following command:

    MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin --verbose --all-databases --routines --triggers > /root/all-databases.sql

  2. Stop MariaDB:

    service mariadb stop

  3. Remove additional mariadb-bench package if installed:

    rpm -e --nodeps mariadb-bench

  4. For security reasons, copy the database directory in a separate folder:

    cp -v -a /var/lib/mysql/ /var/lib/mysql_backup

  5. Check if the mariadb-server package is already installed:

    rpm -q --whatprovides mariadb-server

    If it is installed and the command above gives output, remove using the following command:

    rpm -e --nodeps `rpm -q --whatprovides mariadb-server`

  6. Configure MariaDB repository:

    Warning: MariaDB 10.4 and later versions are supported since 18.0.30, make sure the latest Plesk version is installed.

    Here is an example for MariaDB 10.5:

    6.1. The following command adds the MariaDB 10.5 repository:

    curl -LsS | sudo bash -s -- --mariadb-server-version=10.5

    Note: Make sure that other MariaDB repositories are not enabled in /etc/yum.repos.d/.

  7. Reset all the cache:

    yum clean all

  8. Start an upgrade of MariaDB:

    yum install MariaDB-client MariaDB-server MariaDB-compat MariaDB-shared

  9. In case upgrading to MariaDB 10.6 or newer it is needed to adjust the my.cnf configuration file to match the new requirements:

    sed -i 's/bind-address = ::ffff: =' /etc/my.cnf

  10. start MariaDB:

    systemctl restart mariadb


    systemctl restart mysql

  11. Upgrade MySQL databases:

    MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin

  12. Restart mysql service:

    systemctl restart mariadb


    systemctl restart mysql

  13. Execute this command to update the package version inside Plesk:

    plesk sbin packagemng -sdf

Note: After an upgrade, there may appear 'mysql' init script. It should be removed to avoid conflicts with MariaDB service. The same commands can be used to fix already existing conflict:

systemctl stop mysql; killall mysqld # to stop the incorrect service if it is started
# rm -f /etc/init.d/mysql && systemctl daemon-reload # to remove the incorrect service script and reload systemctl configuration
# systemctl start mariadb # to start MariaDB if not started
# systemctl enable mariadb # to make sure that MariaDB will start after the server reboot automatically









เราขอขอบคุณในความพยายามของคุณ และจะพยายามแก้ไขบทความดังกล่าว