Migrate MySQL to MariaDB in CentOs6.5

Source: Internet
Author: User
Next, we will extract a background, and then the operation records for migrating from mysql5.31 to MariaDB5.5.31 on CentOS6.4. Finally, I found a better migration method.

1. Background

MySQL is the most popular open source relational database in the world. In 2008, Sun acquired MySQL. Then in 2010, Oracle acquired Sun again, so MySQL fell into the hands of Oracle. Oracle has never had a good relationship with the open-source community, and even MySQL has been made community and enterprise, so it cannot be used for free. The new features of MySQL Enterprise Edition are not open source code, which makes users uncomfortable. MariaDB does not have this problem. Compared with MySQL, MariaDB has the following advantages:

Free for commercial use (MySQL Community Edition and Enterprise Edition, thanks to Oracle)

Maria storage engine

PBXT storage engine

XtraDB Storage Engine

FederatedX storage engine

Faster query and processing of replication

Thread pool

Faster running

More extended functional modules

Supports Unicode sorting

So I decided to first look at how to migrate MySQL to MariaDB on the virtual machine, although it is unpredictable that I don't know when Michael Widenius will sell MariaDB to which big company.

In the past, MariaDB was designed to be fully compatible with MySQL, including APIs and client protocols, so that it can easily become a substitute for MySQL. Therefore, migrating from MySQL to MariaDB can basically be called an "upgrade ", it's like a software upgrade. MariaDB's technical documentation is written as follows:

For the same basic version (such as 5.5), you can directly uninstall MySQL and install MariaDB. You do not even need to back up and restore the database. Of course, it is necessary to back up all databases before the upgrade, just in case.

If the main version of MariaDB is high, you need to use mysql_upgrade to upgrade it after you uninstall MySQL and install MariaDB. Yes, even the command line is the same as when MySQL is used.

All the original clients and connectors (PHP, Perl, Python, Java, etc.) can work normally without any changes, because MariaDB and MySQL use the same client protocol, the client library files are also binary compatible.

2. migration operation records (the method 3 below is better)

This VPS is installed with CentOS. The current version is 6.4, and the MySQL version is 5.5.31 (the remi source is used). the configurations of virtual machines are extremely similar. I didn't know much about it at the beginning. I performed this silly operation.

A. configure the installation source of MARIADB first.

Currently, MariaDB's main version is 5.5, and my CentOS is 32-bit. Save the following installation source configuration as MariaDB. repo:/etc/yum. repos. d folder:

[Mariadb] name = MariaDB enable = 1 priority = 3 baseurl = http://yum.mariadb.org/5.5/centos6-x86 gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck = 1

Priority = 3 is the PRIORITIES priority plug-in for YUM.

B. uninstall the original MYSQL and related packages.

# Yum remove mysql *

Use * to delete all mysql data packets (including other packages deleted due to package dependency, such as postfix ). Because conflicts may occur during direct installation, for example:

File/usr/share/mysql/ukrainian/errmsg. sys from install of MariaDB-server-5.5.31-1.i686 conflicts with file from package mysql-libs-5.5.32-1.el6.remi.i686

Well, it seems that because php-mysql is also deleted (in fact this should not be deleted), phpMyAdmin is also deleted because of the dependency. I did not take a closer look.

Therefore, it is best not to use wildcard *, but to selectively delete several main,

# Yum remove mysql-server mysql-libs

But I didn't test it again, because there are better methods later.

C. install MARIADB and the corresponding PHP extension.

It also specifies several major installation packages, and the rest allows yum to perform dependency checks on its own.

# Yum install MariaDB-server MariaDB-client php-mysql

Or, if MariaDB-server is not installed, change to MariaDB Galera cluster with the synchronous multi-master Cluster feature:

# Yum install MariaDB-Galera-server MariaDB-client galera

The funny thing is that I did not pay attention to uninstalling php-mysql. as a result, I ran the database and accessed WordPress. The result encountered the following error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

D. complete and patch

No matter whether the version is upgraded or not, there is no harm in executing the database upgrade command:

# Mysql_upgrade-p

Check whether the database version has been upgraded:

# Mysql-u root-p-e 'show global variables like "version"; 'Enter password: + --------------- + -------------- + | Variable_name | Value | + --------------- + ---------------- + | version | 5.5.31-MariaDB | + ----------------- + ---------------- +

Add MariaDB to the auto-start list with the system,

# Chkconfig -- levels 345 mysql on

Well, in the past MySQL was mysqld, and now mysql, a letter d is missing.

Start it,

# Service mysql start

At this time, the website on the server should be able to work normally and there is no problem in accessing the database.

If necessary, you can reinstall the postfix after installing MariaDB. If phpMyAdmin prompts that you have no access permission, it is uninstalled and you need to reinstall and configure phpMyAdmin.

In addition, the configuration files of MySQL and phpMyAdmin have been cleared and need to be reconfigured. In particular, the MySQL configuration file/etc/my. cnf, because although MariaDB creates a my. cnf. d folder to store your configuration file, but it will first load my. cnf, and the content in the [mysqld] section of the original MySQL configuration is still valid.

3. better upgrade methods

In the system configuration described above, add the MariaDB installation source and then directly execute the system upgrade,

# Yum update -- skip-broken

MariaDB-related installation packages will be installed, and unwanted MySQL packages will be uninstalled. you do not need to fix the system after the upgrade. Look at the previous part of the output:

========================================================== ========================================================== ============================ Package Arch Version Repository Size ====== ========================================================== ========================================================== ======================================== Installing: mariaDB-Galera-server i686 5.5.29-1 mariadb 19 M replacing mysql. i686 5.5.21-1. the el6.remi replacing mysql-server.i686 5.5.21-1. el6.remi MariaDB-server i686 5.5.31-1 mariadb 32 M replacing mysql-server.i686 5.5.21-1. el6.remi MariaDB-shared i686 5.5.31-1 mariadb 1.0 M replacing mysql-libs.i686 5.5.21-1. el6.remi kernel i686 2.6.32-358.11.1.el6 updates 24 M libjpeg-turbo i686 1.2.1-1. el6 base 176 k replacing libjpeg. i686 6b-46.el6 Updating :.........

Here, I feel that MariaDB's design philosophy is that the seamless replacement of MySQL is not a gimmick, but a real technology. So I am not in a rush to upgrade the VPS to MariaDB. anyway, it will not be long before CentOS will adopt MariaDB. then we will migrate it naturally.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.