兴国资源网 Design By www.nnzcdc.com

准备数据库(MySQL),若已有MySQL,可忽略.

build MySQL table;

连接MySQL;

mysql -u root -p

创建数据表;

mysql> create database demo;

mysql> use demo;

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

添加数据表内容;

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

exit();     ----退出MySQL

backup MySQL;

前情提示,启用二进制;

备份数据表;备份my.cnf;

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

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



del MySQL;

停止MySQL服务;

$ sudo service mysql stop //RHEL6

$ sudo systemctl stop mysql //RHEL7

$ sudo /etc/init.d/mysql stop //RHEL6

移除MySQL配置及文件;

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

$ sudo rm -rf /var/lib/mysql

build mariadb;

安装 mariadb;以及相关依赖包;

$ sudo vi /etc/yum.repos.d/MariaDB.repo  //创建自定义的yum源

.......................................  //以下为文件内容

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/5.5/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

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

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

恢复my.cnf文件;

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

启动mariadb;

$ sudo service mariadb start

$ sudo systemctl start mariadb

$ sudo /etc/init.d/mariadb start

MySQL == MARIADB;

将数据表导入到mariadb中;

$ mysql -u root -p < backupdb.sql

出现一下内容,表示登录成功;恭喜你;

$ mysql -u root -p

......................................//以下为sql命令

MariaDB [(none)]> show databases;

MariaDB [(none)]> use test01;

MariaDB [test01]> select * from pet;

兴国资源网 Design By www.nnzcdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
兴国资源网 Design By www.nnzcdc.com