DBA应用技巧中如何利用MySQL技能学习MongoDB
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,DBA应用技巧中如何利用MySQL技能学习MongoDB,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。(1)、mongorestor
千家信息网最后更新 2025年02月01日DBA应用技巧中如何利用MySQL技能学习MongoDB
DBA应用技巧中如何利用MySQL技能学习MongoDB,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
(1)、mongorestore恢复工具 我们先看一下此工具的帮助信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [root@localhost bin]# ./mongorestore --help usage: ./mongorestore [options] [directory or filename to restore from ] options: --help produce help message -v [ --verbose ] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -h [ --host ] arg mongo host to connect to ( --port arg server port. Can also use --host hostname:port --ipv6 enable IPv6 support (disabled by default) -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path --directoryperdb if dbpath specified, each db is in a separate directory -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) --objcheck validate object before inserting --filter arg filter to apply before inserting --drop drop each collection before import --oplogReplay replay oplog for point-in-time restore [root@localhost bin]# |
例如我们先将"foo"库删除了:
1 2 3 4 5 6 7 8 9 10 11 12 | [root@localhost bin]# ./mongo MongoDB shell version: 1.8.1 connecting to : test > use foo switched to db foo > db.dropDatabase(); { "dropped" : "foo" , "ok" : 1 } > show dbs admin 0.0625GB local (empty) test 0.0625GB > |
然后下面我们将演示如何恢复这个库:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [root@localhost bin]# ./mongorestore --directoryperdb /data/dump connected to : 127.0.0.1 Sun Apr 22 12:01:27 /data/dump/foo/t1.bson Sun Apr 22 12:01:27 going into namespace [foo.t1] Sun Apr 22 12:01:27 2 objects found Sun Apr 22 12:01:27 /data/dump/foo/t2.bson Sun Apr 22 12:01:27 going into namespace [foo.t2] Sun Apr 22 12:01:27 1 objects found Sun Apr 22 12:01:27 /data/dump/foo/system.users.bson Sun Apr 22 12:01:27 going into namespace [foo.system.users] Sun Apr 22 12:01:27 1 objects found Sun Apr 22 12:01:27 /data/dump/foo/system.indexes.bson Sun Apr 22 12:01:27 going into namespace [foo.system.indexes] Sun Apr 22 12:01:27 { name : "_id_" , ns: "foo.system.users" , key : { _id: 1 }, v: 0 } Sun Apr 22 12:01:27 { name : "_id_" , ns: "foo.t2" , key : { _id: 1 }, v: 0 } Sun Apr 22 12:01:27 { name : "_id_" , ns: "foo.t1" , key : { _id: 1 }, v: 0 } Sun Apr 22 12:01:27 3 objects found [root@localhost bin]# |
通过工具返回信息,我们可以看到foo中的数据已经被恢复回来了, 接下来我们到库里去验证一下:
1 2 3 4 5 6 7 8 9 10 11 | [root@localhost bin]# ./mongo MongoDB shell version: 1.8.1 connecting to : test > use foo switched to db foo > show collections; system.indexes system.users t1 t2 > |
结果证明foo库表已经被成功恢复回来了。
关于DBA应用技巧中如何利用MySQL技能学习MongoDB问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
代码
工具
问题
帮助
应用技巧
技巧
技能
学习
应用
信息
更多
解答
易行
成功
接下来
简单易行
内容
小伙
小伙伴
数据
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
数据库下线是什么意思
plsql填写数据库
珠海服务软件开发常见问题
.net如何更新数据库
数据库安全审计在哪里
c# 登录局域网服务器
数据库系统函数功能
计算机数据库的题怎么做
rust服务器怎么选pve的
服务器硬盘一般多少转
陕西精益管理软件开发
河南新乡dns服务器虚拟主机
wbe开发与软件开发
如何将数据库备份到本地
能用于城域网的网络技术
网络技术群吗
web服务器命令
线上实践平台网络安全方面
中国刑警网络安全专业
云服务器系统名称
太仓电子网络技术费用是多少
fedora 服务器
千奎网络技术服务
东方道迩软件开发面试
取2个数据后的数据库
数据库推广的软件
双网服务器设置网闸
香港的云服务器
社会安全之网络安全
莫吉娜网络技术