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;