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
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章