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

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

2019年03月27日 22:55:53 zhangpeterx 阅读数 544更多

个人分类: mongodb

晚上在安装mongodb,设置密码后,如果直接连接mongodb,不用密码,虽然可以连上,但是会无法切换到指定数据库:

-> # 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

解决方法是连接时加上密码:

-> # 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

转载于:https://my.oschina.net/u/3367404/blog/3062161

你可能感兴趣的:(shell,数据库)