myloader恢复mysql数据库示例
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了myloader恢复mysql数据库示例,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3462字,纯文字阅读大概需要5分钟。
内容图文
有关mydumper的相关参考
mydumper备份mysql数据库示例
mydumper安装及安装故障汇总
1、单库的备份与恢复
[root@app ~]# mydumper -u leshami -p xxx -B sakila -o /tmp/bak
[root@app ~]# mysql -urobin -pxxx -e "show databases"|grep restoredb
[root@app ~]# mysql -urobin -pxxx \
> -e "create table sakila.tb like sakila.actor; ###创建测试表
> insert into sakila.tb select * from sakila.actor"
###将备份库恢复到一个新数据库,如restoredb
[root@app ~]# myloader -u leshami -p xxx -B restoredb -d /tmp/bak
[root@app ~]# mysql -urobin -pxxx -e "show databases"|grep restoredb
restoredb
###恢复到原库
[root@app ~]# myloader -u leshami -p xxx -B sakila -d /tmp/bak
** (myloader:3642): CRITICAL **: Error restoring sakila.category from file sakila.category-schema.sql: Table ‘category‘ already exists
---增加-o参数进行覆盖恢复
[root@app ~]# myloader -u leshami -p xxx -o -B sakila -d /tmp/bak
2、单表恢复
[root@app ~]# mysql -urobin -pxxx -e "drop table sakila.tb"
[root@app ~]# mysql -urobin -pxxx -e "select count(*) from sakila.tb"
Warning: Using a password on the command line interface can be insecure.
ERROR 1146 (42S02) at line 1: Table ‘sakila.tb‘ doesn‘t exist
###直接调用备份的schema以及数据文件执行即可
[root@app ~]# mysql -urobin -pxxx \
> -e "use sakila;
> source /tmp/bak/sakila.tb-schema.sql
> source /tmp/bak/sakila.tb.sql"
###验证结果
[root@app ~]# mysql -urobin -pxxx -e "select count(*) from sakila.tb"
Warning: Using a password on the command line interface can be insecure.
+----------+
| count(*) |
+----------+
| 200 |
+----------+
3、实例级别的备份与恢复
[root@app ~]# rm -rf /tmp/bak/*
[root@app ~]# mydumper -u leshami -p xxx --regex ‘^(?!(mysql|test))‘ -o /tmp/bak
###尝试删除部分数据库
[root@app ~]# mysql -urobin -pxxx \
> -e "drop database tempdb;drop database sakila"
###基于全部备份文件进行恢复
[root@app ~]# myloader -u leshami -p xxx -o -d /tmp/bak
4、获取帮助
[root@app ~]# myloader --help
Usage:
myloader [OPTION...] multi-threaded MySQL loader
Help Options:
-?, --help Show help options
Application Options:
-d, --directory Directory of the dump to import
-q, --queries-per-transaction Number of queries per transaction, default 1000
还原期间每个事务insert的数目,缺省是1k
-o, --overwrite-tables Drop tables if they already exist(表存在即覆盖)
-B, --database An alternative database to restore into
-e, --enable-binlog Enable binary logging of the restore data
-h, --host The host to connect to
-u, --user Username with privileges to run the dump
-p, --password User password
-P, --port TCP/IP port to connect to
-S, --socket UNIX domain socket file to use for connection
-t, --threads Number of threads to use, default 4
-C, --compress-protocol Use compression on the MySQL connection
-V, --version Show the program version and exit
-v, --verbose Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2
版权声明:本文为博主原创文章,未经博主允许不得转载。
myloader恢复mysql数据库示例
标签:database sql dba mysql
本文系统来源:http://blog.csdn.net/leshami/article/details/46817937
内容总结
以上是互联网集市为您收集整理的myloader恢复mysql数据库示例全部内容,希望文章能够帮你解决myloader恢复mysql数据库示例所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。