0

Trying to get started with mongodb and I have it installed manually, but cant seem to go forward past this point

mongod --dbpath path_to_my_app\data

I am a bit unclear on how to set the PATH, pretty sure the location of the binaries is not being set right. How would I go about this part of the problem?

MongoDb version = 3.0.2, OS X 10.9.5

Edit: Okay i figured where the issue was, it was the way i was declaring the path i was missing a directory ~/missing/path_to_app.

Raj
  • 107
  • 1
  • 3
  • 11
  • Which version are you trying to install? and you're using which OS? – Gaurav Dave Apr 14 '15 at 07:13
  • What error are you getting? If you installed from source try `export PATH = $PATH:/path/to/mongod` – Sammaye Apr 14 '15 at 07:17
  • MongoDB version as well as OS info will be helpful. Also make sure your have the right permission to write into directory path_to_my_app\data – user2829759 Apr 14 '15 at 07:23
  • the error i get is mongod command not found, i have added the specs for the version in the OP – Raj Apr 14 '15 at 07:32
  • if command is not found then normally you need to export your path var or install it via homebrew, installing via homebrew is easier – Sammaye Apr 14 '15 at 08:30
  • @Sammaye so i installed homebrew and mongo through and seem to be getting I STORAGE [initandlisten] exception in initAndListen: Users/raj/Mongo_Test/nodetest1/data not found. It looks like the path is the issue again – Raj Apr 14 '15 at 16:59
  • Have you tried configuring it's path via the conf file that runs it? http://stackoverflow.com/questions/11600006/how-to-create-a-configuration-file-for-mongodb – Sammaye Apr 15 '15 at 13:54

1 Answers1

0

Try these steps:

  1. Install MongoDB

1.1 Configure the package management system (APT)

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

1.2 Create a /etc/apt/sources.list.d/mongodb.list file using the following command.

echo ‘deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

1.3 reload repository

sudo apt-get update

1.4 install the package

sudo apt-get install mongodb-10gen

or

sudo apt-get install mongodb-10gen=2.4.10

for a specific version

1.5 (optional) To pin a package to avoid unintended auto-upgrade

echo “mongodb-10gen hold” | sudo dpkg –set-selections

  1. Run MongoDB

2.1 Start

sudo service mongodb start (or sudo service mongod start)

2.2 Stop

sudo service mongodb stop (or sudo service mongod stop)

2.3 Restart

sudo service mongodb restart (or sudo service mongod restart)

2.4 check status

sudo service mongodb status (or sudo service mongod status)

  1. Use MongoDB (Manual from console)

3.1 Connect to a Database

mongo –port port-number –host host-name

e.g. mongo –port 27017 –host localhost

3.2 Select a DB

use db-name

3.3 all commands are very easy-to-understand and straightforward, “help” will show all of them.

3.4. Add users and passwords

Mongo DB allows localhost exception after initial installation before creating any users/passwords, meaning that it allows access to any connection requests (client or console) without username and password. You can create user and password as follows:

3.4.1 connect via “mongo” console command in terminal (sudo may be required)

shell: mongo

MongoDB shell version: 2.6.0 connecting to: test

3.4.2 switch to admin table

use admin

switched to db admin

3.4.3 create/dorp/show the user

db.createUser({user: “user”,pwd: “password”,roles:[{role: “userAdminAnyDatabase”,”db” : “admin”}, {“role” : “readWrite”,”db” : “admin”}]})

Successfully added user: { “user” : “federatedwireless”, “roles” : [ { “role” : “userAdminAnyDatabase”, “db” : “admin” }, { “role” : “readWrite”, “db” : “admin” } ] }

db.dropUser(“user”)

show users

3.4.4 restart mongo

sudo service mongodb restart (or sudo service mongod status)

note: the defaulted installed mongo start command did not enable the authentication, it runs like below:

/usr/bin/mongod –config /etc/mongodb.conf

After adding user as above, clients are only asked for credential when try to use database but not on connecting to the database server/cluster. Also local exception is still available. You will need to enable the authentication by changing the start command to

/usr/bin/mongod –auth –config /etc/mongodb.conf

  1. Use MongoDB in applications (via MongoDB Drivers and Client Librapgadmin3ries)

4.1 Available MongoDB Drivers and Client Libraries

JavaScript
Python
Ruby
PHP
Perl
Java
Scala
C#
C
C++
Haskell
Erlang
  1. Mongo Admin/Management GUIs

There are a lot of 3rd party GUI apps available for administrating and managing MongoDB. I installed a web based mViewer. Installation is simply download and extract that package to you desired directory (e.g. ~/workplace/db-admin/mongo) and start it in that directory via

/start_mViewer.sh

Where port is optional and default is 8080.

you can then access the GUI web page via http://server-URI:8080/index.html

  1. Allow remote client to connect to MongoDB

The default configuration comes with Mongo package only allows local connections. To allows remote clients, need to modify the Mongo config file “/etc/mongodb.conf” as instructed in the config file:

Listen to local interface only. Comment out to listen on all interfaces.

bind_ip = 127.0.0.1

comment out “bind_ip = 127.0.0.1″ as

bind_ip = 127.0.0.1

will allow remote clients.

(Reference: Tuts)

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39