当前位置:Gxlcms > 数据库问题 > mac安装mongodb

mac安装mongodb

时间:2021-07-01 10:21:17 帮助过:2人阅读

> db.createUser({user:"root",pwd:"username",roles:[{role:"userAdminAnyDatabase", db: "admin" }]}) Successfully added user: { "user" : "root", "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] } ?
2,重启服务

./mongod --auth  --dbpath /Users/username/app/mongoDB/mongodb-osx-x86_64-3.0.7/data/db/?

?

3 ,使用

db.auth("root","username")?



> show dbs

2015-11-03T17:43:10.813+0800 E QUERY    Error: listDatabases failed:{

"ok" : 0,

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",

"code" : 13

}

    at Error ()

    at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)

    at shellHelper.show (src/mongo/shell/utils.js:630:33)

    at shellHelper (src/mongo/shell/utils.js:524:36)

    at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47

> db.auth("root","username")

Error: 18 Authentication failed.

0

> db.auth("root","username")

Error: 18 Authentication failed.

0

> use admin

switched to db admin

> db.auth("root","username");

1

> show dbs;

admin  0.078GB

local  0.078GB

test   0.078GB

> 

四,远程连接

mongo 远程主机ip或DNS:MongoDB端口号/数据库名 -u user -p password?

五,可视化工具

Robomongo

mac版本: http://mac.softpedia.com/get/Developer-Tools/Robomongo.shtml?

技术分享

下载好后,输入连接参数,mongodb默认端口号是27017。mongodb默认没有权限限制的,如果有在Authentication里面配置就好。?

 

技术分享

mac版 mongodb可视化工具robomongo

 

可视化工具貌似不支持mongodb3.0版本,我连接本地认证报错,问题解决链接未试,暂时未解决(待尝试),不过非认证模式和远程链接均没问题。

?

?六,问题解决

1,用户权限问题

正宗解决方法:ibruce.info/2015/03/03/mongodb3-auth/

用户权限问题(另一种解决方式)

21jhf.iteye.com/blog/2216103?

2,启动服务报警告

http://www.bkjia.com/sjkqy/997187.html?

3,mongodb 常用命令

http://www.cnblogs.com/xusir/archive/2012/12/24/2830957.html?

mac安装mongodb

标签:

人气教程排行