SoFunction
Updated on 2025-03-09

Tutorial on migrating the project from MYSQL to MARIADB

Prepare the database (MySQL), if there is already MySQL, it can be ignored.

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;

Previous prompts, enable binary system;

Backup data table; backup;

$ mysqldump --all-databases --user=root --password --master-data > 

$ sudo cp /etc/mysql/ /opt/



del MySQL;

Stop MySQL service;

$ sudo service mysql stop //RHEL6

$ sudo systemctl stop mysql //RHEL7

$ sudo /etc//mysql stop //RHEL6

Remove MySQL configuration and files;

$ sudo yum remove mysql* mysql-server mysql-devel mysql-libs

$ sudo rm -rf /var/lib/mysql

build mariadb;

Install mariadb; and related dependency packages;

$ sudo vi /etc/// // Create a custom yum source

....................................  //The following is the content of the file

[mariadb]

name = MariaDB

baseurl = /5.5/centos7-amd64

gpgkey=/RPM-GPG-KEY-MariaDB

gpgcheck=1

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

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

Recover files;

$ sudo cp /opt/   /etc/mysql/

Start mariadb;

$ sudo service mariadb start

$ sudo systemctl start mariadb

$ sudo /etc//mariadb start

MySQL ==>> MARIADB;

Import the data table into mariadb;

$ mysql -u root -p <

The content appears to indicate that the login is successful; congratulations;

$ mysql -u root -p

.....................................//The following is the sql command

MariaDB [(none)]> show databases;

MariaDB [(none)]> use test01;

MariaDB [test01]> select * from pet;