Upgrade mysql to mariadb centos 7

This article provides instructions for upgrading  MariaDB 5.5 to 10.0/10.1/10.2 on Linux.

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.

  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 --all-databases --routines --triggers > /tmp/all-databases.sql

  2. Stop MariaDB:

    # service mariadb stop

  3. Remove additional packages like mariadb-bench:

    # rpm -e --nodeps mariadb-bench

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

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

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

    # rpm -q --whatprovides mysql-server

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

    # rpm -e --nodeps `rpm -q --whatprovides mysql-server`

  6. Configure MariaDB repository: open the Setting MariaDB repositories page, select your OS distro, release and a desired MariaDB version. Once done, the configuration that should be added to the /etc/yum.repos.d/MariaDB.repo file will appear.

    Here is an example for MariaDB 10.2:

    6.1. Open/create the MariaDB.repo file in any text editor. In this example, we are using the vi editor:

    # vi /etc/yum.repos.d/MariaDB.repo

    6.2. Add the content below to the file:

    [mariadb]
    name = MariaDB
    baseurl = //yum.mariadb.org/10.2/centos7-amd64
    gpgkey=//yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1

    6.3. Save the changes and close the file.

  7. Start an upgrade of MariaDB:

    # yum install MariaDB-client MariaDB-server

  8. Once the upgrade is finished, start MariaDB:

    # service mariadb start

    OR

    # service mysql start

  9. Upgrade MySQL databases:

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

  10. Restart mysql service:

    # service mariadb restart

    OR

    # service mysql restart

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

    # plesk sbin packagemng -sdf

    Note: After an upgrade to 10.2 version, there may appear 'mysql' init script. It can be removed.

    # rm /etc/init.d/mysql
    # systemctl daemon-reload

In this tutorial we are going to provide you with step-by-step instructions on how to upgrade MariaDB on a CentOS 7 VPS. MariaDB is an open source, community-developed fork of the MySQL relational database management system. MariaDB is highly compatible with MySQL, ensuring exact matching with MySQL commands and APIs.

The upgrade process should take about 10 minutes if you follow the easy steps described below.

In order to check the current MariaDB version installed on your server, run the following command:

mysql -V
mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux [x86_64] using readline 5.1

Upgrade MariaDB from 5.5.x version to 10.2.x version

Before starting with the upgrade procedure, create a backup of your MariaDB databases:

mysqldump -uroot -p --all-databases > /opt/database-dump.sql

Stop the MariaDB service with the following command:

systemctl stop mariadb

Remove MariaDB 5.5.x packages:

yum remove mariadb mariadb-server mariadb-libs
Removing:
 mariadb                                                x86_64                                         1:5.5.56-2.el7                                          @base                                          49 M
 mariadb-libs                                           x86_64                                         1:5.5.56-2.el7                                          @base                                         4.4 M
 mariadb-server                                         x86_64                                         1:5.5.56-2.el7                                          @base                                          58 M
Removing for dependencies:
 net-snmp                                               x86_64                                         1:5.7.2-28.el7                                          @base                                         850 k
 perl-DBD-MySQL                                         x86_64                                         4.023-5.el7                                             @base                                         323 k
 php-mysql                                              x86_64                                         5.4.16-42.el7                                           @base                                         232 k
 postfix                                                x86_64                                         2:2.10.1-6.el7                                          @base                                          12 M

Transaction Summary
===================================================================================================================================================================================================================
Remove  3 Packages [+4 Dependent packages]

Installed size: 125 M
Is this ok [y/N]: y

...

Removed:
  mariadb.x86_64 1:5.5.56-2.el7                                     mariadb-libs.x86_64 1:5.5.56-2.el7                                     mariadb-server.x86_64 1:5.5.56-2.el7

Dependency Removed:
  net-snmp.x86_64 1:5.7.2-28.el7                     perl-DBD-MySQL.x86_64 0:4.023-5.el7                     php-mysql.x86_64 0:5.4.16-42.el7                     postfix.x86_64 2:2.10.1-6.el7

Complete!

Add a new MariaDB repository:

vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = //yum.mariadb.org/10.2/centos7-amd64
gpgkey=//yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Clean the repository cache on your server with:

yum clean all

Install MariaDB 10.2

Install MariaDB 10.2.x version using the following command:

yum install MariaDB-client MariaDB-server
Installing:
 MariaDB-server                                           x86_64                                    10.2.9-1.el7.centos                                           mariadb                                    108 M
Installing for dependencies:
 MariaDB-client                                           x86_64                                    10.2.9-1.el7.centos                                           mariadb                                     48 M
 MariaDB-common                                           x86_64                                    10.2.9-1.el7.centos                                           mariadb                                    155 k
 MariaDB-compat                                           x86_64                                    10.2.9-1.el7.centos                                           mariadb                                    2.8 M
 boost-program-options                                    x86_64                                    1.53.0-27.el7                                                 base                                       156 k
 galera                                                   x86_64                                    25.3.20-1.rhel7.el7.centos                                    mariadb                                    8.0 M

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package [+5 Dependent packages]

Total download size: 167 M
Installed size: 708 M
Is this ok [y/d/N]: y

...

Installed:
  MariaDB-server.x86_64 0:10.2.9-1.el7.centos

Dependency Installed:
  MariaDB-client.x86_64 0:10.2.9-1.el7.centos         MariaDB-common.x86_64 0:10.2.9-1.el7.centos         MariaDB-compat.x86_64 0:10.2.9-1.el7.centos         boost-program-options.x86_64 0:1.53.0-27.el7
  galera.x86_64 0:25.3.20-1.rhel7.el7.centos

Complete!

Please note, you need to install Postfix and php-mysql packages if you used them prior this upgrade, so run:

yum install postfix php-mysql

Enable MariaDB service to automatically start on server boot:

systemctl enable mariadb

Start the MariaDB service:

systemctl start mariadb

Run the mysql_upgrade command-line command to examine all tables in all MariaDB databases for incompatibilities with the currently installed version of the MariaDB server:

mysql_upgrade

If everything is OK, check the currently installed MariaDB version with:

mysql -V

mysql  Ver 15.1 Distrib 10.2.9-MariaDB, for Linux [x86_64] using readline 5.1

Set the MariaDB root user password and secure MariaDB

There is no MariaDB root user password set by default. Use the following command to set a new MariaDB root user password, remove the anonymous users, secure MariaDB by restricting the remote login for root user and remove the test database.

mysql_secure_installation

That is it. MariaDB has been successfully installed on your server.

If you use one of our Linux Host Support  services, you  can simply ask our expert Linux admins to upgrade MariaDB on your CentOS 7 server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

How do I upgrade MySQL to MariaDB?

Steps to Migrate Data From MySQL to MariaDB.
Step 1: Create MySQL Database Backup..
Step 2: Uninstall MySQL Database Packages..
Step 3: Install MariaDB Database Packages..
Step 4: Load MySQL Backup File to MariaDB..

How do I switch from MySQL to MariaDB in Linux?

To upgrade from MariaDB to MySQL you need to perform the follow simple steps:.
stop MariaDB's mysqld process..
install the binary files of 5.7..
start mysqld & run mysqld_upgrade..
run MySQL Shell's upgrade checker utility..
stop mysqld..
upgrade the binaries to MySQL 8.0..

How do I get MariaDB on CentOS 7?

Install MariaDB 5.5 on CentOS 7.
Install the MariaDB package using the yum package manager: sudo yum install mariadb-server. ... .
Once the installation is complete, start the MariaDB service and enable it to start on boot using the following commands: sudo systemctl start mariadb sudo systemctl enable mariadb..

How do I upgrade MariaDB 5.5 to MariaDB 10.0 on CentOS 7?

How to Upgrade.
Modify the repository configuration, so the system's package manager installs MariaDB 10.0. ... .
Set innodb_fast_shutdown to 0 . ... .
Stop MariaDB..
Uninstall the old version of MariaDB. ... .
Install the new version of MariaDB. ... .
Make any desired changes to configuration options in option files, such as my. ... .
Start MariaDB..

Bài mới nhất

Chủ Đề