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.
Related
I'm taking a full WebDev course and got really hard stuck on this matter. I've installed postgreSQL 14.2 for Windows 10 and the instructor said that pgAdmin4 would come together, which it didn't, so then i installed pgAdmin4 individually. I've setted everything up and created a testing database, which is called 'test', and also a table, everything through Windows Powershell command lines, following the course instructions. Now, when i try to access this database through PowerShell command psql 'test' and type the requested password for the OS user i get a Fatal Error, which follows:
PS C:\Users\theu_\desktop> psql 'test'
Password for user theu_:
psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "theu_"
I've tried my OS username password and the postgreSQL password, none of them works. What am i missing or did wrong?
Thanks in advance
Try accessing postgres by using psql -U postgres in cmd, postgres being the name of the superuser for postgres itself (if you did a basic install) - while windows is probably trying to access postgres with your windows name.
You should also be able to use SQL Shell to access your database without denoting a user.
I'm trying to connect to database restored from disk snapshot. I have new VM with ubuntu 18.04. I installed postgres, postgres-client and postgres-contrib from *.deb files. Then I mounted managed disk into machine with database and tried to connect - no success.
Postgres server running good, cluster ok, status ok, pg_isready ok. Until I change the data_directory in postgresql.conf from default to mounted - /snapshot_data_path/. After that my cluster is down and I cannot use psql in postgres (error ~ .s.PGSQL missing. File dissapearing from default directory).
chown -R to /snapshot_data_path - done, looks ok.
I think my database is running manualy when I use :
/usr/lib/postgresql/9.5/bin/postgres -d 3 -D /database/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf with that new path. EDIT: Error, I can connect but no data inside.
I try search over the internet for similar problems - no luck.
Is it possible to take database from 1 VM and connect it with another fresh VM? Or I must use pg_dump to achieve that?
Here the official documentation on this topic: https://www.postgresql.org/docs/9.0/backup-file.html
The database server must be shut down in order to get a usable backup.
Did you shutdown the server while the data snapshot was taken?
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
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.
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.