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数据库报错

mongodb相关报错-----持续整理_第1张图片

解决:参考问题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
 

 

你可能感兴趣的:(mongodb相关报错-----持续整理)