admin管理员组

文章数量:1130349

问题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://wwwblogs/herosoft/p/8399974.html

           https://wwwblogs/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

问题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://wwwblogs/herosoft/p/8399974.html

           https://wwwblogs/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

本文标签: 报错mongodb