0

I've been told by my professor to use linux to install nodejs, expressjs, and mongoDB. I've installed mongodb from the terminal, but when I try to execute the command "mongo", I get this:

MongoDB shell version: 2.6.10 
connecting to: test 
2018-01-20T11:58:05.602-0500 warning: Failed to connect to 
127.0.0.1:27017, reason: errno:111 Connection refused 
2018-01-20T11:57:05.603-0500 Error: couldn't connect to server 
127.0.0.1:27017 (127.0.0.1), connection attempt failed at 
src/mongo/shell/mongo.js:146 
exception: connect failed
  • Possible duplicate of [Connection refused to MongoDB errno 111](https://stackoverflow.com/questions/24899849/connection-refused-to-mongodb-errno-111) – Nilesh Singh Jan 20 '18 at 17:08
  • Have you started the `mongod` process? – 5ar Jan 20 '18 at 17:10
  • @5ar no i haven't. sorry i'm trying to find tutorials cause i'm starting from a blank slate – TheNubProgrammer Jan 20 '18 at 17:19
  • @5ar how do i do the mongod process on a linux? I've seen command lines on how to do it on mac and windows – TheNubProgrammer Jan 20 '18 at 17:22
  • If you are on Ubuntu `sudo service mongod start` - https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#run-mongodb-community-edition – 5ar Jan 20 '18 at 17:24
  • @5ar can i run this command in any path location or must I be in a specific directory? – TheNubProgrammer Jan 20 '18 at 17:31
  • Any path if you have `mongod` in your PATH variables - follow the instructions on the link in my previous comment :) – 5ar Jan 20 '18 at 17:33
  • @5ar ooh! I got it! It's saying that i "data/db" doesn't exist when i ran it. So i tried to create a directory like it said in the tutorial but I'm getting "permission denied" can't make directory of 'data/'. Sorry for pestering you. – TheNubProgrammer Jan 20 '18 at 17:45
  • @5ar: Those commands aren’t friends, those commands actually are plainly stupid and wrong. Chmodding a file to be executable which isn’t supposed to be executable can wreak havoc security wise. The correct way is to identify the euid MongoDB is supposed to run under (`mongodb` under Ubuntu, iirc) and make sure the permissions of the files and directories allow the process to read and write the files and “execute” (enter) the directories. – Markus W Mahlberg Jan 20 '18 at 18:20
  • I strongly suggest reading the [installation instructions for MongoDB on Ubuntu, aka “the docs”](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/) – Markus W Mahlberg Jan 20 '18 at 18:22
  • @MarkusWMahlberg True, I was focused on the fact that this is obviously some kind of homework assignment and in those the usual answer to permission problems in those is that, I deleted the comment so no one gets any wrong ideas in the future. Sorry for providing bad information. – 5ar Jan 20 '18 at 18:48

0 Answers0