MYSQL ==>> MARIADB

來源:互聯網
上載者:User

標籤:blank   .sql   提示   move   org   baseurl   table   二進位   target   

準備資料庫(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;

本文到此結束,歡迎來訪;

詳情請點擊<<MARIADB官方文檔>>

MYSQL ==>> MARIADB

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.