设为首页 加入收藏

TOP

CentOS-6.5下MariaDB-10基于XtraBackup备份工具的原理及配置详解(四)
2014-11-24 03:16:27 来源: 作者: 【 】 浏览:13
Tags:CentOS-6.5 MariaDB-10 基于 XtraBackup 备份工具 原理 配置 详解
iaDB [hellodb]> set session sql_log_bin=0;

4.12 恢复刚刚保存在tmp下文件:

MariaDB [hellodb]> source /tmp/inc.sql

4.13 开启二进制日志:

MariaDB [hellodb]> set session sql_log_bin=1;

4.14 查看hellodb中的表是否还原:

MariaDB [hellodb]> SHOW TABLES;

+--------------------------+

| Tables_in_hellodb |

+--------------------------+

| classes |

| coc |

| courses |

| scores |

| students |

| teachers |

| toc |

| xioam1 |

+--------------------------+

4.16 查看表中的数据是否还原:

MariaDB [hellodb]> SELECT * FROM xioam1;

+------+

| id |

+------+

| 1 |

| 2 |

| 3 |

| 4 |

+------+

4.17 查看xiaoma2库:

MariaDB [hellodb]>

MariaDB [hellodb]> use xiaoma2

Database changed

MariaDB [xiaoma2]> SHOW TABLES;

+-------------------+

| Tables_in_xiaoma2 |

+-------------------+

| hehe1 |

+-------------------+

(三)导入或导出单张表的实现???

假如说我想实现期望能够把hellodb中students表中的数据导出来,每一张表都给他单独进行导出。

1.1 将之前的所有备份删除,以免出问题,后备份:

[root@localhost ~]# rm -rf /mybackups/*

[root@localhost ~]# innobackupex --user=root /mybackups/

一般出现此行就可以了。

140307 14:16:20 innobackupex: completed OK!

[root@localhost ~]#

1.2 导出表:

[root@localhost ~]# innobackupex --apply-log --export /mybackups/2014-03-07_14-16-07/

一般出现此行就可以了。

xtrabackup: starting shutdown with innodb_fast_shutdown = 0

InnoDB: FTS optimize thread exiting.

InnoDB: Starting shutdown...

InnoDB: Shutdown completed; log sequence number 1745942

140307 14:18:14 innobackupex: completed OK!

[root@localhost ~]#

1.3 查看导出的表(看.exp的):

[root@localhost ~]# cd /mybackups/2014-03-07_14-16-07/hellodb/

[root@localhost hellodb]# ls

classes.cfg coc.exp courses.frm scores.frm students.ibd testtb.cfg toc.exp xioam1.frm

classes.exp coc.frm courses.ibd scores.ibd teachers.cfg testtb.exp toc.frm xioam1.ibd

classes.frm coc.ibd db.opt students.cfg teachers.exp testtb.frm toc.ibd

classes.ibd courses.cfg scores.cfg students.exp teachers.frm testtb.ibd xioam1.cfg

coc.cfg courses.exp scores.exp students.frm teachers.ibd toc.cfg xioam1.exp

[root@localhost hellodb]#

1.4 导入表(要在mysql服务器上导入来自于其它服务器的某innodb表,需要先在当前服务器上创建一个跟原表表结构一致的表,而后才能实现将表导入):

MariaDB [(none)]> use hellodb

MariaDB [hellodb]> SHOW CREATE TABLE students;

将如下命令复制后并且执行:

CREATE TABLE `students` (

`StuID` int(10) unsigned NOT NULL AUTO_INCREMENT,

`Name` varchar(50) NOT NULL,

`Age` tinyint(3) unsigned NOT NULL,

`Gender` enum('F','M') NOT NULL,

`ClassID` tinyint(3) unsigned DEFAULT NULL,

`TeacherID` int(10) unsigned DEFAULT NULL,

PRIMARY KEY (`StuID`)

) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8

MariaDB [hellodb]>

2.1 创建一个mydb库:

MariaDB [hellodb]> CREATE DATABASE mydb;

MariaDB [hellodb]> use mydb;

2.2 在mydb中创建表students:

MariaDB [mydb]> CREATE TABLE `students` (

-> `StuID` int(10) unsigned NOT NULL AUTO_INCREMENT,

-> `Name` varchar(50) NOT NULL,

-> `Age` tinyint(3) unsigned NOT NULL,

-> `Gender` enum('F','M') NOT NULL,

-> `ClassID` tinyint(3) unsigned DEFAULT NULL,

-> `TeacherID` int(10) unsigned DEFAULT NULL,

-> PRIMARY KEY (`StuID`)

-> ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8

-> ;

MariaDB [mydb]>

2.3 查看表结构:

MariaDB [mydb]> DESC students;

+-----------+---------------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+-----------+---------------------+------+-----+---------+----------------+

| StuID | int(10) unsigned | NO | PRI | NULL | auto_increment |

| Name | varchar(50) | NO | | NULL | |

| Age | tinyint(3

首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇mysql基础知识回顾 下一篇初学hibernate,调用session的sav..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)