Project migration from MYSQL to MARIADB tutorial, mysql migration mariadb

Source: Internet
Author: User

Project migration from MYSQL to MARIADB tutorial, mysql migration mariadb

Prepare the database (MySQL). If MySQL already exists, ignore it.

build MySQL table;

Connect to MySQL;

mysql -u root -p

Create a data table;

mysql> create database demo;mysql> use demo;mysql> create table pet(name varchar(30), owner varchar(30), species varchar(20), sex char(1));

Add data table content;

mysql> insert into pet values('brandon','Jack','puddle','m'),('dixie','Danny','chihuahua','f');

Exit (); ---- exit MySQL

Backup MySQL;

Preference prompt: Enable binary;

Back up data tables; back up my. cnf;

$ mysqldump --all-databases --user=root --password --master-data > backupdb.sql$ sudo cp /etc/mysql/my.cnf /opt/my.cnf.bak

Del MySQL;

Stop the MySQL service;

$ sudo service mysql stop //RHEL6$ sudo systemctl stop mysql //RHEL7$ sudo /etc/init.d/mysql stop //RHEL6

Remove MySQL configurations and files;

$ sudo yum remove mysql* mysql-server mysql-devel mysql-libs$ sudo rm -rf /var/lib/mysql

Build mariadb;

Install mariadb and related dependent packages;

$ Sudo vi/etc/yum. repos. d/MariaDB. repo // create a custom yum Source

....................................... // The content of the file is as follows:

[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/5.5/centos7-amd64gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1

.......................................

$ Sudo yum install MariaDB-server MariaDB-client // install MariaDB

Restore the my. cnf file;

$ sudo cp /opt/my.cnf   /etc/mysql/

Start mariadb;

$ sudo service mariadb start$ sudo systemctl start mariadb$ sudo /etc/init.d/mariadb start

MySQL ==>> MARIADB;

Import the data table to mariadb;

$ mysql -u root -p < backupdb.sql

If the message appears, the logon is successful. Congratulations;

$ mysql -u root -p

...................................... // The following is an SQL command

MariaDB [(none)]> show databases;MariaDB [(none)]> use test01;MariaDB [test01]> select * from pet;

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.