河南省建设银行网站年报,天津设计师网站,app内测分发平台,凡客装修一、安装MongoDB
忽略 二、创建账号和授权
在新的MongoDB上创建用户管理员。先切换到admin库#xff0c;然后通过命令创建数据库管理员账号和密码。最后再验证账号密码是否创建成功#xff01;
use admin
db.createUser({user:root,pwd:123456Ab,…
一、安装MongoDB
忽略 二、创建账号和授权
在新的MongoDB上创建用户管理员。先切换到admin库然后通过命令创建数据库管理员账号和密码。最后再验证账号密码是否创建成功
use admin
db.createUser({user:root,pwd:123456Ab,roles:[userAdminAnyDatabase]})
db.auth(root,123456Ab) #返回1表示登录成功
过程记录
C:\Users\administratormongo
MongoDB shell version v3.6.23
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceNamemongodb
Implicit session: session { id : UUID(9c8640d6-7b58-4220-b2a5-286938940a38) }
MongoDB server version: 3.6.23
Welcome to the MongoDB shell.
For interactive help, type help.
For more comprehensive documentation, seehttp://docs.mongodb.org/
Questions? Try the support grouphttp://groups.google.com/group/mongodb-useruse admin
switched to db admindb.createUser({user:root,pwd:123456Ab,roles:[userAdminAnyDatabase]})
Successfully added user: { user : root, roles : [ userAdminAnyDatabase ] }db.auth(root,123456Ab)
1exit
byeC:\Users\administrator
在指定数据库上创建用户。
先切换到admin库然后验证刚刚创建的管理root账号再切换到新的ramsey数据库通过命令创建账号和授权。
use admin
db.auth(root,123456Ab)
use ramsey
db.createUser({user:ss,pwd:secret,roles:[{role:dbOwner, db:ramsey}]})
过程记录
C:\Users\administratormongo
MongoDB shell version v3.6.23
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceNamemongodb
Implicit session: session { id : UUID(930e2c76-530e-4345-8840-4705075e2646) }
MongoDB server version: 3.6.23use admin
switched to db admindb.auth(root,123456Ab)
1use ramsey
switched to db ramseydb.createUser({user:ss,pwd:secret,roles:[{role:dbOwner, db:ramsey}]})
Successfully added user: {user : ss,roles : [{role : dbOwner,db : ramsey}]
}exit
byeC:\Users\administrator
三、恢复Mongodb数据
通过下面命令恢复数据
-- restore
mongorestore -h 127.0.0.1 --port 27017 -u ss -p secret -d ramsey C:\Mongodump\ramsey C:\Mongodump\ramsey\restore.log
过程记录
C:\Users\administratormongorestore -h 127.0.0.1 --port 27017 -u ss -p secret -d ramsey C:\Mongodump\ramsey C:\Mongodump\ramsey\restore.log
2024-07-16T15:17:24.8180800 the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2024-07-16T15:17:24.8200800 building a list of collections to restore from C:\Mongodump\ramsey dir
2024-07-16T15:17:24.8270800 dont know what to do with file C:\Mongodump\ramsey\restore.log, skipping...
2024-07-16T15:17:24.8330800 reading metadata for ramsey.sent_item from C:\Mongodump\ramsey\sent_item.metadata.json
2024-07-16T15:17:24.8380800 reading metadata for ramsey.sent_item_archive from C:\Mongodump\ramsey\sent_item_archive.metadata.json
2024-07-16T15:17:24.8390800 reading metadata for ramsey.failed_item from C:\Mongodump\ramsey\failed_item.metadata.json
2024-07-16T15:17:24.9040800 reading metadata for ramsey.failed_item_archive from C:\Mongodump\ramsey\failed_item_archive.metadata.json
2024-07-16T15:17:24.9150800 restoring ramsey.sent_item from C:\Mongodump\ramsey\sent_item.bson
2024-07-16T15:17:24.9500800 restoring ramsey.failed_item from C:\Mongodump\ramsey\failed_item.bson
2024-07-16T15:17:24.9640800 restoring ramsey.sent_item_archive from C:\Mongodump\ramsey\sent_item_archive.bson
2024-07-16T15:17:25.7330800 restoring ramsey.failed_item_archive from C:\Mongodump\ramsey\failed_item_archive.bson
2024-07-16T15:17:28.1840800 [........................] ramsey.sent_item 47.7MB/6.46GB (0.7%)
2024-07-16T15:17:28.1860800 [######..................] ramsey.failed_item 49.0MB/176MB (27.7%)
2024-07-16T15:17:28.1910800 [........................] ramsey.sent_item_archive 42.6MB/1.30GB (3.2%)
2024-07-16T15:17:28.1920800 [###############.........] ramsey.failed_item_archive 48.6MB/73.9MB (65.8%)
2024-07-16T15:17:28.1930800
2024-07-16T15:17:29.8700800 [########################] ramsey.failed_item_archive 73.9MB/73.9MB (100.0%)
2024-07-16T15:17:29.8790800 no indexes to restore
2024-07-16T15:17:29.8860800 finished restoring ramsey.failed_item_archive (7526 documents)
2024-07-16T15:17:29.8920800 reading metadata for ramsey.sending from C:\Mongodump\ramsey\sending.metadata.json
2024-07-16T15:17:29.9340800 restoring ramsey.sending from C:\Mongodump\ramsey\sending.bson
2024-07-16T15:17:29.9400800 no indexes to restore
2024-07-16T15:17:29.9420800 finished restoring ramsey.sending (0 documents)
2024-07-16T15:17:30.8080800 [........................] ramsey.sent_item 108MB/6.46GB (1.6%)
2024-07-16T15:17:30.8200800 [##############..........] ramsey.failed_item 107MB/176MB (60.4%)
2024-07-16T15:17:30.8470800 [#.......................] ramsey.sent_item_archive 104MB/1.30GB (7.9%)
2024-07-16T15:17:30.8500800
2024-07-16T15:17:33.7480800 [........................] ramsey.sent_item 169MB/6.46GB (2.6%)
2024-07-16T15:17:33.7500800 [#####################...] ramsey.failed_item 156MB/176MB (88.3%)
2024-07-16T15:17:33.7530800 [###.....................] ramsey.sent_item_archive 179MB/1.30GB (13.5%)
2024-07-16T15:17:33.7580800
2024-07-16T15:17:34.3480800 [########################] ramsey.failed_item 176MB/176MB (100.0%)
2024-07-16T15:17:34.3480800 no indexes to restore
2024-07-16T15:17:34.3550800 finished restoring ramsey.failed_item (18145 documents)
2024-07-16T15:17:36.7570800 [........................] ramsey.sent_item 263MB/6.46GB (4.0%)
2024-07-16T15:17:36.7570800 [#####...................] ramsey.sent_item_archive 303MB/1.30GB (22.9%)
2024-07-16T15:17:36.7610800
2024-07-16T15:17:39.7490800 [#.......................] ramsey.sent_item 313MB/6.46GB (4.7%)
2024-07-16T15:17:39.7530800 [#######.................] ramsey.sent_item_archive 431MB/1.30GB (32.5%)
2024-07-16T15:17:39.7580800
2024-07-16T15:17:42.7480800 [#.......................] ramsey.sent_item 361MB/6.46GB (5.5%)
2024-07-16T15:17:42.7480800 [#########...............] ramsey.sent_item_archive 548MB/1.30GB (41.3%)
2024-07-16T15:17:42.7550800
2024-07-16T15:17:45.7480800 [#.......................] ramsey.sent_item 426MB/6.46GB (6.4%)
2024-07-16T15:17:45.7490800 [############............] ramsey.sent_item_archive 675MB/1.30GB (50.9%)
2024-07-16T15:17:45.7550800
2024-07-16T15:17:48.7480800 [#.......................] ramsey.sent_item 490MB/6.46GB (7.4%)
2024-07-16T15:17:48.7490800 [###############.........] ramsey.sent_item_archive 842MB/1.30GB (63.4%)
2024-07-16T15:17:48.7500800
2024-07-16T15:17:51.7480800 [##......................] ramsey.sent_item 616MB/6.46GB (9.3%)
2024-07-16T15:17:51.7500800 [##################......] ramsey.sent_item_archive 1014MB/1.30GB (76.4%)
2024-07-16T15:17:51.7530800
2024-07-16T15:17:54.8530800 [##......................] ramsey.sent_item 719MB/6.46GB (10.9%)
2024-07-16T15:17:54.8540800 [####################....] ramsey.sent_item_archive 1.13GB/1.30GB (87.1%)
2024-07-16T15:17:54.8770800
2024-07-16T15:17:57.7480800 [##......................] ramsey.sent_item 812MB/6.46GB (12.3%)
2024-07-16T15:17:57.7520800 [#######################.] ramsey.sent_item_archive 1.28GB/1.30GB (98.9%)
2024-07-16T15:17:57.7580800
2024-07-16T15:17:58.1150800 [########################] ramsey.sent_item_archive 1.30GB/1.30GB (100.0%)
2024-07-16T15:17:58.1150800 no indexes to restore
2024-07-16T15:17:58.1200800 finished restoring ramsey.sent_item_archive (135502 documents)
2024-07-16T15:18:00.7480800 [###.....................] ramsey.sent_item 940MB/6.46GB (14.2%)
2024-07-16T15:18:03.7700800 [####....................] ramsey.sent_item 1.09GB/6.46GB (16.9%)
2024-07-16T15:18:06.7480800 [####....................] ramsey.sent_item 1.23GB/6.46GB (19.0%)
2024-07-16T15:18:09.7700800 [#####...................] ramsey.sent_item 1.43GB/6.46GB (22.1%)
2024-07-16T15:18:12.7470800 [#####...................] ramsey.sent_item 1.58GB/6.46GB (24.5%)
2024-07-16T15:18:15.7490800 [######..................] ramsey.sent_item 1.76GB/6.46GB (27.3%)
2024-07-16T15:18:18.7560800 [######..................] ramsey.sent_item 1.87GB/6.46GB (29.0%)
2024-07-16T15:18:21.7470800 [#######.................] ramsey.sent_item 2.06GB/6.46GB (31.8%)
2024-07-16T15:18:24.8000800 [########................] ramsey.sent_item 2.25GB/6.46GB (34.8%)
2024-07-16T15:18:27.7470800 [#########...............] ramsey.sent_item 2.44GB/6.46GB (37.8%)
2024-07-16T15:18:30.7470800 [#########...............] ramsey.sent_item 2.62GB/6.46GB (40.5%)
2024-07-16T15:18:33.7470800 [##########..............] ramsey.sent_item 2.77GB/6.46GB (42.8%)
2024-07-16T15:18:36.7480800 [##########..............] ramsey.sent_item 2.95GB/6.46GB (45.6%)
2024-07-16T15:18:39.7470800 [###########.............] ramsey.sent_item 3.13GB/6.46GB (48.4%)
2024-07-16T15:18:42.7470800 [############............] ramsey.sent_item 3.34GB/6.46GB (51.7%)
2024-07-16T15:18:45.7480800 [#############...........] ramsey.sent_item 3.52GB/6.46GB (54.5%)
2024-07-16T15:18:48.7580800 [#############...........] ramsey.sent_item 3.70GB/6.46GB (57.3%)
2024-07-16T15:18:51.7500800 [##############..........] ramsey.sent_item 3.87GB/6.46GB (59.9%)
2024-07-16T15:18:54.7470800 [###############.........] ramsey.sent_item 4.09GB/6.46GB (63.3%)
2024-07-16T15:18:57.7470800 [################........] ramsey.sent_item 4.31GB/6.46GB (66.8%)
2024-07-16T15:19:00.7840800 [################........] ramsey.sent_item 4.53GB/6.46GB (70.1%)
2024-07-16T15:19:03.7600800 [#################.......] ramsey.sent_item 4.71GB/6.46GB (72.9%)
2024-07-16T15:19:06.7470800 [##################......] ramsey.sent_item 4.94GB/6.46GB (76.4%)
2024-07-16T15:19:09.7470800 [###################.....] ramsey.sent_item 5.13GB/6.46GB (79.4%)
2024-07-16T15:19:12.7470800 [###################.....] ramsey.sent_item 5.34GB/6.46GB (82.7%)
2024-07-16T15:19:15.8440800 [####################....] ramsey.sent_item 5.57GB/6.46GB (86.2%)
2024-07-16T15:19:18.7480800 [#####################...] ramsey.sent_item 5.79GB/6.46GB (89.7%)
2024-07-16T15:19:21.7470800 [######################..] ramsey.sent_item 6.00GB/6.46GB (92.9%)
2024-07-16T15:19:24.7470800 [#######################.] ramsey.sent_item 6.21GB/6.46GB (96.2%)
2024-07-16T15:19:27.8160800 [#######################.] ramsey.sent_item 6.40GB/6.46GB (99.1%)
2024-07-16T15:19:28.7620800 [########################] ramsey.sent_item 6.46GB/6.46GB (100.0%)
2024-07-16T15:19:28.7620800 restoring indexes for collection ramsey.sent_item from metadata
2024-07-16T15:20:13.6270800 finished restoring ramsey.sent_item (676453 documents)
2024-07-16T15:20:13.6270800 doneC:\Users\administrator