mongodb:E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:4

Mongodb error: e query [thread1] syntax error: missing; before statement @(shell):1:4

March 27, 2019 22:55:53 zhangpeters read 544 more

Personal classification: mongodb

After installing mongodb at night and setting the password, if you directly connect to mongodb without password, you can connect to it, but you cannot switch to the specified database

-> # mongo                            
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
> 1+1
2
> ues admin
2019-03-27T22:42:21.838+0800 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:4

1

2

3

4

5

6

7

8

9

The solution is to add a password when connecting:

-> # mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.6.3
> use test
switched to db test

Similar Posts: