MongoDB 语法错误:丢失;声明之前@(shell)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38772594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:47:23  来源:igfitidea点击:

MongoDB SyntaxError: missing ; before statement @(shell)

mongodb

提问by Tim

When I try to invoke methods of a collection, why is there an error of SyntaxError: missing ; before statement @(shell)? Thanks.

当我尝试调用集合的方法时,为什么会出现错误SyntaxError: missing ; before statement @(shell)?谢谢。

$ mongo
MongoDB shell version: 3.2.8
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] 
2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] 
2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] 

> show dbs
mydb   0.000GB
local  0.000GB
> use mydb
switched to db mydb
> show collections
201607012
> db
mydb
> mydb.201607012.find()
2016-08-04T12:10:23.826-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:4

> db.201607012.find()
2016-08-04T12:10:29.000-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

> db.201607012.find()
2016-08-04T12:11:09.115-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

> db.201607012.stats()
2016-08-04T12:13:06.022-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

采纳答案by tarashypka

According to documentation

根据文档

Collection names should begin with an underscore or a letter character

集合名称应以下划线或字母字符开头

Check hereor herehow to remove or access your wrongly named collection.

点击这里点击这里如何删除或访问您错误地命名集合。

回答by Surendra Parchuru

exit from mongoshell with quit() and try to run command in regular command prompt, it will work

使用 quit() 从 mongoshell 退出并尝试在常规命令提示符下运行命令,它将起作用

回答by Kevin Niasta

You have to open new cmd and run as administrator then write mongoexport. It worked in my mongoDB

您必须打开新的 cmd 并以管理员身份运行,然后编写 mongoexport。它在我的 mongoDB 中有效