programing

MongoDB 구문 오류: 누락; 문 @(shell) 앞

javajsp 2023. 6. 28. 21:19

MongoDB 구문 오류: 누락; 문 @(shell) 앞

컬렉션의 메서드를 호출하려고 하면 다음 오류가 발생하는 이유는 무엇입니까?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

quit()로 mongoschell을 종료하고 일반 명령 프롬프트에서 명령을 실행하려고 하면 작동합니다.

문서에 따르면

컬렉션 이름은 밑줄 또는 문자로 시작해야 합니다.

잘못 명명된 컬렉션을 제거하거나 액세스하는 방법을 여기 또는 여기에서 확인하십시오.

새 cmd를 열고 관리자로 실행한 다음 mongoexport를 작성해야 합니다.내 몽고DB에서 작동했습니다.

언급URL : https://stackoverflow.com/questions/38772594/mongodb-syntaxerror-missing-before-statement-shell