mongodb篇 — mongodb相关报错 _ 持续整理

问题1:

db.res_query_field.find({id:5bed}).pretty()
> [Error] SyntaxError: identifier starts immediately after numeric literal
at line 1, column 29
> 时间: 0.004s

语法错误:没有加双引号

正确的语法

db.res_query_field.find({"id":"5bed"}).pretty()

 

问题2:

mongo-3.4.16的数据通过客户端导出为sql文件后导入mongo-4.2.8报错:

[ERR] [13][Unauthorized] not authorized on test0 to execute command { drop: "UploadMC.chunks", $db: "test0", lsid: { id: UUID("01464972-62a5-4825-9660-a93eb54292cf") } }

$ docker exec -it mongo mongo admin

>  db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'}]})

> db.auth('admin', '123456')

以上是已经做过的操作,主要是以下这条命令:

授权读写的权限

> db.grantRolesToUser("admin", [ { role: "readWrite", db: "test0" } ])

 

参考https://www.cnblogs.com/herosoft/p/8399974.html

           https://www.cnblogs.com/cheyunhua/p/9021333.html

补充

用mongo客户端导出数据600M需要1分10秒,导入耗时3分10秒【导入的数据库的服务器只有1G内存,所以慢些】

 

问题3:

启动mongo失败,报错:

# docker start mongo
Error response from daemon: driver failed programming external connectivity on endpoint mongo (8585de875654cf0b448bc8700486dcfbd0faade4171948d37bbf607332180b8b):  (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.2 --dport 27017 -j ACCEPT: iptables: No chain/target/match by that name.
 (exit status 1))
Error: failed to start containers: mongo


解决

# systemctl restart docker
# docker start mongo

 

问题4:

连接mongo数据库报错

解决:参考问题2的解决办法

 

问题5:

> db.auth('admin'.'123456')
2020-06-22T04:03:01.926+0000 E  QUERY    [js] uncaught exception: SyntaxError: missing name after . operator :
@(shell):1:16

解决

> db.auth("admin","123456")
1
 

 

问题6:win版mongo3.0.1导出数据报错

E:\mongodb-win32-3.0.1-ShiGuai\bin>mongodump  --port 28012 --authenticationDatabase admin -d xcverifyDB  -o E:\mongodb-win32-3.0.1-ShiGuai\backup\xcverifyDB_20200715

ERROR: unknown option authenticationDatabase

解决:用其他的mongo库下的mongump命令

原因:猜测该库下bin目录下可能有损坏文件

 

问题7:win版mongo3.0.1导出的数据为空

E:\mongodb-win32-3.0.1-ShiGuai\bin>mongodump.exe --port 28012 -d xcverifyDB -o E:\mongodb-win32-3.0.1-ShiGuai\backup\xcverifyDB20200715

解决:加一个参数 --authenticationDatabase admin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值