One, install Method 1, download MongoDB
1, the official website to download MongoDB program Https://www.mongodb.org/downloads#production?
2. Start MongoDB Service after decompression
Download and place under the/user/username/app/mongodb
TAR-ZXVF mongodb-osx-x86_64-3.0.7.tgz
New data file storage directory entry?/user/name/app/mongodb/mongodb-osx-x86_64-3.0.7
mkdir? data
CD data/
mkdir db?
Into the/user/name/app/mongodb/mongodb-osx-x86_64-3.0.7/bin?
Start the MongoDB service and configure the MongoDB file storage directory
./mongod--dbpath/user/username/app/mongodb/mongodb-osx-x86_64-3.0.7/data/db/?
Note that there will be information to print, do not close the window
?
3, start a new window, start the MongoDB client window, use MongoDB
Start a new window Command+n
Enter into?/user/name/app/mongodb/mongodb-osx-x86_64-3.0.7/bin
Execute the./mongo command
Enter? MongoDB shell command Status
Now it's time to write the MongoDB shell.
4, warning solutions to improve ...
? Two, installation Method 2,brew installation
1, first install brew
2, refer to MongoDB official website installation method, recommended to use Method 1 installation.
Third, users and roles
1, create user
> Use adminswitched to DB admin> Db.createuser ({User: "root", pwd: "username", Roles:[{role: " Useradminanydatabase ", DB:" admin " }]}) Successfully added User: {" user ":" Root "," Roles " : [{ "Role": "Useradminanydatabase","db": "Admin"}]}?
2, restart the service./mongod--auth--dbpath/users/username/app/mongodb/mongodb-osx-x86_64-3.0.7/data/db/??3, using Db.auth ("Root", "username")?>Show DBS2015-11-03t17:43:10.813+0800E QUERY error:listdatabases failed:{"OK": 0,"ErrMsg": "Not authorized in 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:18authentication failed.0> Db.auth ("root", "username") Error:18authentication failed.0>Use adminswitched to DB admin> Db.auth ("Root", "username");1>Show Dbs;admin0. 078GBlocal0. 078GBtest0. 078GB>
Four, remote connection
MONGO remote host IP or DNS:MONGODB port number/database name-u user-p password?
Five, visualization tools
Robomongo
Mac Version: Http://mac.softpedia.com/get/Developer-Tools/Robomongo.shtml?
After downloading, enter the connection parameters, the MongoDB default port number is 27017. MongoDB default does not have permission restrictions, if there is authentication inside the configuration is good.?
Mac version of MongoDB Visualizer Robomongo
The visualizer does not seem to support the mongodb3.0 version, I connect local authentication error, the problem resolution link is not tried, temporarily unresolved (to try), but the non-authentication mode and remote link is not a problem.
?
? Six, Problem solving
1, User permissions issues
Authentic Solution: ibruce.info/2015/03/03/mongodb3-auth/
User rights issues (another workaround)
21jhf.iteye.com/blog/2216103?
2, start the service report warning
Http://www.bkjia.com/sjkqy/997187.html?
3,mongodb Common Commands
Http://www.cnblogs.com/xusir/archive/2012/12/24/2830957.html?
Mac Install MongoDB