Use same mongodb database over Windows 7 & Ubuntu - windows

I would like to use the same MongoDB database I use on windows 7 as I do on Ubuntu.
On Ubuntu, I went into the file: /etc/mongodb.conf
and changed dbpath=/var/lib/mongodb to dbpath=/media/meaniostack/OS/data/db which is the database on the windows partition.
When I tried starting up mongod & mongo, I got the following error:
MongoDB shell version: 2.6.7
connecting to: test
2015-01-30T14:19:11.027-0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-01-30T14:19:11.028-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
However, when I go back to dbpath=/var/lib/mongodb, it works like normal. Keep in mind, that I have mounted media/meaniostack/OS
How do I make this work, and is it possible? Does mongodb, use a different type of storage compared to the one in Ubuntu?

After a bit of messing around I found the solution to be:
Alter permissions to the folders that the database is in.
Change the mongodb.conf path variable
Use mongod --dbpath /media/meaniostack/OS/data/db instead of: service mongod start
Hope this helped anyone with a similar issue.

Related

How to connect to mongo shell from windows cmd?

This is my first time using Mongodb, It connect normally using the IDE from Mongodb university basics m001 course but when I tried to connect from cmd it won't connect and gives me this error
*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
Error: Authentication failed. :
connect#src/mongo/shell/mongo.js:374:17 #(connect):2:6 exception:
connect failed exiting with code 1
I added the path to my environment & checked the network access from my Atlas and I can connect to it from anywhere
Can anyone help me with this please??

psql: could not connect to server: No such file or directory on Windows

When I try to connect to my postgresql database with psql I receive the error message:
D:\>psql -U postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5112"?
A similar error I get when using createdb:
createdb: could not connect to database template1: could not connect to server: No such file or directory
next two lines are identical to the psql error.
I can start pgadminIII without problems and access my databases. when I check the properties of the connection it uses port 5432. When using process explorer I see about 5 postgresql processes, though none accessing port 5432. The solutions I found in this forum are about linux/osx platforms, which I am not able to translate into a windows solution.
Could anybody tell what is wrong/what I am doing wrong and suggest a solution?
Thanks for your time.

Local Mongo on Windows - couldn't connect to server 127.0.0.1:27017, connection attempt failed

Installed Mongo 3.2 on Windows 8.1. Got this:
c:\foo>"c:\Program Files\MongoDB\Server\3.2\bin\mongo.exe"
MongoDB shell version: 3.2.5
connecting to: test
2016-04-26T13:41:31.032+0100 W NETWORK [thread1] Failed to connect to 127.0.0.1
:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-04-26T13:41:31.034+0100 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
c:\foo>ver
Microsoft Windows [Version 6.3.9600]
Why?
What else can I say?
I got the same error this is how i solved it.
open your task manager
click on service tab
check for Mongo Db service
and right click restart it.
hopefully this will solved it.
You have to start the server process first.
https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-windows/#run-mongodb
First, you should install Mongodb as a service,
Open your cmd as admin
Run ( net start mongodb )
Now you can run the command ( mongo ) and you will be able to connect normally, with no Problem.

Can't access mongoDB outside server

I've set up a mongod service on centOS. I've played around with DBs, collections, etc - after connecting using 'localhost', 27017.
That said, for some reason I can't connect to it from outside SSH. I'm using the ruby mongo gem to try and connect to mydomain.com:27017 and I get the following error:
Mongo::ConnectionFailure: Failed to connect to a master node at xx.xx.xx.xx:27017
How can I figure out what's wrong?

PostgreSQL first time install and attempt to connect

I just installed postgresql-9.1.4-1-windows-x64 on a Windows 7 64 bit machine. I'm having trouble starting the service and connecting to a database.
After a successful installation I've tried the following based on similar postings.
1) Looked for "Start Server" under Start > All Programs > PostreSQL 9.1 and could not find it.
2) Tried starting the server from the command line
pg_ctl.exe -D "C:\Program Files\PostgreSQL\9.1\bin\data"
This gave me the error:
could not create lock file 'postmaster.pid': Permission denied
I have administrative rights, and there is not postmaster.pid file either in the bin or data directories.
3) Next I tried starting the Service from Admistrative Tools by right clicking on the postgresql-9.1.4-1-windows-x64 Service and selecting Start. I received the message:
The postgresql-9.1.4-1-windows-x64 Service on local computer started
and stopped. Some services stop automatically if they are not in use
by other services or programs.
The Event Viewer showed the error as Timed out waiting for server startup
4) I figured there the data in the data directory was probably and initial database, but just in case I ran "initdb" and got:
If you want to create a new database system either remove or empty the
directory c:\program files\postgreSql/9.1/data or run initdb with an
argument other than c:\program files\postgreSql/9.1/data
4) And just for fun I Started pgAdminIII, right clicked on "PostreSQL 9.1(localhost:5432)", selected Connect, entered password, and got:
could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "localhost" (::1) and accepting TCP/IP
connections on port 5432?
Does anybody have a suggestion?
Thanks.
«"could not create lock file 'postmaster.pid': Permission denied"»
Do not look any further, Postgres cannot start if it can't create this temp file. If it is not created, you evidently cannot find it if you look for it on the disk. Your DATA directory has been created so no need to re run initdb again and if you try to use pgadmin it complains that it cannot connect to Pg -- which is not running.
I am not familiar with windows but found out where postmaster.pid is to be created you will probably find out why Postgres cannot create this file.
Hope it helps.

Resources