2019年03月27日 22:55:53 zhangpeterx 阅读数 544更多mongodb
我的分类: mongodbshell
晚上在安装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
解决方法是链接时加上密码:spa
-> # 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