Can't connect to mongolab form shell - node.js

I'm trying to connect to mongolab via shell. I get a code from lab.
mongo ds023432.mlab.com:23432/somecol -u fakeusername -p fakepass123
Of course i created a db user on mongolab site. However When i call the above command I get the following error:
MongoDB shell version: 3.2.6 Enter password:
connecting to: ds023432.mlab.com:23432/somecol
2016-05-16T17:55:04.290+0200 E - [main] file [fakepass123] doesn't exist
failed to load: fakepass123
So far I am able to connect only via driver. And I am using Arch linux
What am I missing?

I am using Arch Linux as well with mongo client version 3.2.6 and have the same issue.
I would assume it is a client - server incompatibility (since my java application can connect with its driver)
To solve the issue I've installed robomongo via
yaourt -S robomongo-bin --noconfirm
Notes:
Follow these steps to get yaourt if you don't already have it
I am not affiliated with robomongo - it's just a solution for the problem I was facing

Related

Remote access to an Azure Postgres database

How can I connect to an Azure PostgreSQL database, from a remote machine?
Update 2. I can connect to the database from WSL/Ubuntu using sudo psql, but I can't using plain psql. So it's a permissions issue somewhere...
Update. I've discovered I can connect from the remote machine using PgAdmin4, but I can't connect using psql. So I want to know: how should I connect using psql?
Original question. I can connect to it using psql from a VM inside Azure, so I know the database is up and accepting connections.
But when I try to connect from my home machine, using exactly the same psql command, it fails:
psql --user=UUU --host=HHH DB
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
More information...
On the Azure database's "Connection Security" blade, I have
added a firewall rule with start IP=0.0.0.0 and end IP=255.255.255.255
set "enforce SSL connection" to disabled
turned on "allow access to Azure services".
My home machine is running Windows+WSL, and I'm trying to connect from WSL / Ubuntu 18.04
using psql version 10.11. I run into the same problem whether I try to connect from home or from work, and I'm not blocking any outgoing ports (that I know of).
The database is running PostgreSQL 10.
When I connect (successfully) from an Azure VM, using psql 10.10, it looks like this:
psql --user=UUU --host=HHH DB
Password for user UUU:
psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Maybe your root user uses a different psql binary than your user. ( You can find out using
which psql and sudo which psql )
I Ran into the same connection issue. In my case, the base issue was a postgres major version mismatch.
I was connecting to an Azure Postgresql on version 11 with my local psql on version 12. Downgrading my local machine's Postgres version to 11.6 solved this for me.
Maybe your root user is using psql 10 and your default user is using psql 11 or 12. ( You can check this using psql -V and sudo psql -V )
I had the same issue. The error message sucks and is of 0 help.
You're probably using a different version of psql than your Azure DB. It needs to match whatever is installed in Azure.
So if you provisioned a version 10 DB in Azure, either you install version 10 for the pqsl tool or do a full Postgre version 10 install instead. The point is the major versions need to match between psql and the target database.

pg_upgrade on AWS EC2 linux - pg_hba.conf settings

I am running an Amazon EC2 CentOS 6.6 server instance with pre-installed PostgreSQL 8.4.20 server which I want to upgrade to 9.4.1 using pg_upgrade via SSH.
What I've done so far: Downloaded and installed PostgreSQL 9.4.1 with yum, configured it. Configured the postgres user to have the same password on the UNIX server and for both database instances. Both database instances are functioning correctly - old one on port 5432, new on 5433.
What I am trying to do:
su - postgres
/usr/pgsql-9.4/bin/pg_upgrade
-b /usr/bin/
-B /usr/pgsql-9.4/bin/
-d /var/lib/pgsql/data/
-D /var/lib/pgsql/9.4/data/
Here is my issue with pg_hba.conf. Using
TYPE DATABASE USER METHOD
local all all trust
or
TYPE DATABASE USER METHOD
local all all peer
I can't start the old server, getting:
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
connection to database failed: fe_sendauth: no password supplied
Failure, exiting
Using the default setting
TYPE DATABASE USER METHOD
local all all ident
is the only method that allows me to start the server, but then I get the following error:
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.
connection to database failed: 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.50432"?
could not connect to old postmaster started with the command:
"/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data/" -o "-p 50432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000 -c listen_addresses='' -c unix_socket_permissions=0700" start
Failure, exiting
I have been reading more than 10 hours straight everything related, before I posted this, but can't seem to find the solution. Will be very grateful if you can give me any hints.

Trying to use mongodump with remote server heroku using mongolab

In my computer i'm running this command to make a backup of the information of some mongodb database.
mongodump -h <hostName>:<port> -d <databes> -u <user> -p <pass> -o direction/where/to/make Backup
But gave to me this error:
Failed: error connecting to db server: no reachable servers
I try to connect robomongo with the same user, pass, host and databes and it's work fines.
Version of mongo 3.0.1
Thanks.
This is basically what I figure from this link
The new mongo tool set doesn't work too well with Unix Domain Socket . The issue is still open.
If you're connecting via hostname try using the IP as the link suggests.
Hope this helps.

PDO driver for XAMPP on Linux

I'm about to gain some experience on Yii so I set up a XAMPP (1.8.1) for Linux environment and installed the Yii framework.I progress based on the book titled 'Web Application Development with Yii and PHP' and there's an example to set up database connection and test that through the Yii console by running the following code:
echo Yii::app()->db->connectionString;
Of course previously I created the appropriate MySQL database and set up the connection string in corresponding main.php and console.php but I'm getting an error:
exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /work/webroot/yii/framework/db/CDbConnection.php:382
Based on Yii's requirement checker PDO for MySQL is enabled. If I check the HTML version of phpinfo it says:
PDO Driver for MySQL: Enabled
and
Client API version: mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
However if I run phpinfo from a Yii console it gives the following result:
PDO support => enabled
PDO drivers =>
So, for me it seems PDO driver is missing. I read several forum threads about how to download PDO drivers for linux and how to change the php.ini to use those drivers but I guess that solution works for CLI environment and not for XAMPP.
Can somebody help me out here how can I set up PDO driver for MySQL database on XAMPP? I'm using Ubuntu 13.10 desktop.
I was playing around for a while and found the solution with the help of several forum threads.
To resolve the following driver issue...
'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver'
... I had to install the correct connector. I ran the following:
sudo apt-get install php5-mysql
After that I tried to check the connection string once again via the Yii console by running code:
echo Yii::app()->db->connectionString;
But this time it gave me a different error mesage:
'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
To resolve this issue I changed my main.php and console.php under /protected/config directory and replaced 'localhost' to '127.0.0.1'.
Based on the PHP documentation this is required because MySQL Unix socket shouldn't be used with host or port.
This resolved the second error message and I could connect to my database.

Installing Postgresql and PgAdmin3 on Linux

I use Postgesql and PgAdmin on Windows without any problems but am struggling to get it working on Linux (I'm a Linux N00b). I have installed the 64bit version on my Fedora box following these instructions (except substituting version 9.3 for 9.2). Everything works well until I get to launching pgsql with:
sudo -u postgres psql template1
Here I get an error "Permission denied" as is attempts to change to my home directory.
I can change the password for 'postgres' as per the instructions and I presume this is just so I can use 'md5' rather than 'trust' in pg_hba.conf (if not, then I don't understand why I need this step).
When I fire up PgAdmin3, initially I have no connections. Attempting to connect to the server gives me an authentication error for user 'postgres'. I have tried resetting pg_hba.conf to 'trust' but that doesn't work either.
I would appreciate an explanation of the 'postgres' user in Linux as it appears to be a separate actual user on the Linux system (unlike Windows where it is just a 'disembodied' user relevant only to Postgress). Secondly, help in getting PgAdmin speaking to Postgresql would be gratefully received.
psql -U postgres template1
It will prompt for password if you set md5 in pg_hba.conf
After much digging about I found that most of the documentation is incomplete. I needed a combination of connecting via Cefull Lo's solution (+1) and NOT (as in most of the documentation):
sudo -U postgres psql
Then to change the password I need a more explicit SQL command as follows
template1=# ALTER USER postgres with encrypted password ‘yourpassword’;
I presume that I need to explicitly state 'with encrypted password' because I am using md5, though again, 90% of the documentation fails to point this out and advises a basic change of password together with md5. Maybe this is specific to Fedora, who knows, but now I can connect via PgAdmin3.

Resources