Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB SyntaxError: missing ; before statement @(shell)

Tags:

mongodb

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

$ 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
like image 783
Tim Avatar asked Aug 04 '16 16:08

Tim


3 Answers

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

like image 107
Surendra Parchuru Avatar answered Nov 08 '22 16:11

Surendra Parchuru


According to documentation

Collection names should begin with an underscore or a letter character

Check here or here how to remove or access your wrongly named collection.

like image 11
tarashypka Avatar answered Nov 08 '22 16:11

tarashypka


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

like image 8
Kevin Niasta Avatar answered Nov 08 '22 17:11

Kevin Niasta