SHARE

Hey gang, in this MongoDB tutorial for beginners, I’ll shows you how we can connect to MongoDB using ‘mongodb.connect’. To connect, we’ll need to pass the method a connection string which matches up to the location of our database.

—– COURSE LINKS:
+ Repo – https://github.com/iamshaunjp/mongodb-playlist
+ Atom editor – https://atom.io/a
+ Download GIT – https://git-scm.com/
+ CMDER – http://cmder.net/
+ MongoDB – https://www.mongodb.com/
+ Robomongo – https://robomongo.org/

JS Playlist – https://www.youtube.com/playlist?list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

NODEJS Playlist – https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

ASYNC JS Playlist – https://www.youtube.com/playlist?list=PL4cUxeGkcC9jAhrjtZ9U93UMIhnCc44MH

———————————————————————————————
You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress, Node.js & more on the channel homepage…

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== PSD to WordPress Playlist ==========

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gnow7e45LQFkNVxwQ5BH-W

============ Node.js for Beginners Playlist =============

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

================== Social Links ==================

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

18 COMMENTS

  1. connection error: { MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]

  2. This is what I got when I run the file:
    (node:17788) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`.

  3. Hello Net Ninja, Thanks for your tutorials. My question is that how can i create my own repository…in this tutorial we are cloning from Git. At first i tried to install mongoose without cloning from git it was giving me a no repository warning. I really want to understand this part of the tutorial. Your response will be greatly appreciated .

  4. Hi Shaun, first thanks for all the great tutorials. Here is my question: after running the connection.js file everything seems to work fine. But when I use the terminal (linux) to log into mongo and I do a 'show dbs', the created 'testaroo' database doesn't show up. Any idea why or what is going on here? Thanks again, kind regards.

  5. i tried so many times but its shows an error like this

    C:datadbmongodb-playlist>node test1/connection.js
    connection has been terminated { MongoError: failed to connect to server [locahost:27017] on first connect [MongoError: getaddrinfo ENOTFOUND locahost locahost:27017]
    at Pool.<anonymous> (C:datadbmongodb-playlistnode_modulesmongodb-corelibtopologiesserver.js:328:35)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:188:7)
    at Connection.<anonymous> (C:datadbmongodb-playlistnode_modulesmongodb-corelibconnectionpool.js:280:12)
    at Connection.g (events.js:292:16)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:191:7)
    at Socket.<anonymous> (C:datadbmongodb-playlistnode_modulesmongodb-corelibconnectionconnection.js:177:49)
    at Socket.g (events.js:292:16)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at connectErrorNT (net.js:1021:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    name: 'MongoError',
    message: 'failed to connect to server [locahost:27017] on first connect [MongoError: getaddrinfo ENOTFOUND locahost locahost:27017]' }

  6. hey yo, started watching your node.js and mongodb series this weekend and i am really thankful for your tutorial. stay awesome!
    btw i am really curious what font you are using in this tutorial. would be cool if you could answer <.<

  7. how come you attached the callbacks after attempting to make the connection? Would it be possible for the connection to be made BEFORE those callbacks are attached?

  8. Having to start mongo in the terminal with mongod command, open another shell, cd to mongdb-playlist and then enter node test/connection.js to get it working. Is this the correct way or another way around it…otherwise getting the error you force create with localhostp

LEAVE A REPLY

Please enter your comment!
Please enter your name here