I have a sevrer that has an instance of postgres 9.4 I am using.
I installed another version of postgres (9.6), but have come across an issue.
To init the new db, I ran
sudo -u postgres /usr/pgsql-9.6/bin/initdb -D /var/lib/pgsql/9.6/data/
But when I check the sql, I get the following.
sudo -u postgres /usr/pgsql-9.6/bin/psql
psql (9.6.9, server 9.4.18)
Type "help" for help.
postgres=# SHOW config_file;
config_file
-----------------------------------------
/var/lib/pgsql/9.4/data/postgresql.conf
I can see it is using my 9.4, but I am unsure how to correct this issue, and have not managed to find any resources that indicate how to do so.
Any help would be appreciated.
The 9.4 postgres use the default port and I guess you set another one for postgres 9.6.
Connect to it with psql -P xxxx where xxxx is the 9.6 port number.
Related
I've tried to install postgres 13.1 on my Mac using homebrew. (Also tried versions 11 & 12 which at one time were installed on this Mac, but encountering same error with those versions now). Am using notes I took from previous installs & of course google/stackoverflow. Tried many things/many times, but always, if I run psql, createuser, createdb (any postgres command), it responds with:
FATAL: role "postgres" does not exist
Also tried just creating a postgres user on my Mac to run install from that account; no luck.
Also tried postgresql install from the enterprisedb.com site. That worked, but seems klunky & seems to rely on .sh scripts. Interestingly, got the 'role postgres does not exist' error after the edb install too, but noticed if I just entered 'postgres' twice on the command line it worked. Example:
/Library/PostgreSQL/13/bin/psql -h localhost -p 5432 -U postgres postgres
This trick doesn't work tho with the brew install.
Understand I need to create the postgres role, but I can't find a command to do this that doesn't complain that the role doesn't already exist.
Any help would be so so appreciated!
Most sites documenting postgres install with homebrew said to use commands like:
psql postgres
or
createuser postgres
Those didn't work for me, but this did:
psql -d postgres -U <myUserName>
Attaching a screenshot to try to summarize the install experience & what worked:
screenshot
Can you try:
/Library/PostgreSQL/13/bin/psql
and then:
CREATE USER postgres SUPERUSER;
?
This document solved it for me: https://enrq.me/dev/2021/01/13/fix-role-postgres-does-not-exist/
The gist: run createuser -s postgres -U <os-username>
Hey so after I ran into somes issues I decided to uninstall Postgres and re-install it (re install a newer version btw).
I'm trying to access postgres to create a new db for my Rails app so I run su postgresor su _postgres then I am asked a password but nothing that I enter works.
So I tried sudo -u postgres psql and got
sudo: unknown user: postgres
sudo: unable to initialize policy plugin
I tried also to disable SIP (see: here)
but it didn't work either. same results.
I don't know what to do. Any idea ? I am using Mac OS High Sierra 10.13.6.
Thanks to #gordon Davidson and #wildplasser 's help, I found the solution:
sudo -u myusername psql postgres
I had this same challenge when trying to access a PostgreSQL database.
When I run the command below:
sudo -u postgres psql
I get the error below:
sudo: unknown user: postgres
sudo: unable to initialize policy plugin
The issue was that I did not have the PostgreSQL database server installed on the server. The server only had a MySQL database server set up on it.
That's all.
I hope this helps
From your EC2 node issue the following command to test if database is reachable.
/opt/gitlab/embedded/bin/psql -U YourExistingUsername -d template1 -h AWS-RDS-POSTGRES-ENDPOINT
When I issued the command:
psql -h localhost -U ruanpc
The console fails to connect to localhost postgres db and display:
psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility
My postgres and psql versions are:
ruanpc#slave-40:~$ postgres --version
postgres (PostgreSQL) 11devel
ruanpc#slave-40:~$ psql --version
psql (PostgreSQL) 11devel
Any one knows how to solve it?
Your psql loads a libpq with version 9.5 or older. Make sure to use the same version of libpq as the psql version.
Oh, I forget to set the LD_LIBRARY_PATH to point to Postgres shared library!
Easy fix for me!
After I deployed hdfs, map reduce, hawq, pxf with ambari, I have generated about 10G data on hdfs using impala-tpcds-kits.
But when I login in Postgres with the user postgres, I can't use the command line CREATE EXTERNAL TABLE to index the data on hdfs. And when I use psql help command, there isn't the key word CREATE EXTERNAL TABLE.
I don't know why?
Last login: Thu Aug 25 15:08:15 2016 from 192.168.1.50
[root#hadoop-m-21 ~]# su postgres
bash-4.1$ psql
psql (8.4.20)
Type "help" for help.
postgres=# CREATE EXTERNAL TABLE EXT_LOG_INFO (hight int,weight int)
LOCATION ('pxf://10.0.0.21:51200/tmp/test2.txt?PROFILE=HdfsTextSimple')
FORMAT 'TEXT' (DELIMITER '|');
ERROR: syntax error at or near "EXTERNAL"
LINE 1: CREATE EXTERNAL TABLE EXT_LOG_INFO (hight int,weight int) LO...
^
You aren't connecting to HAWQ.
[root#hadoop-m-21 ~]# su postgres
bash-4.1$ psql
psql (8.4.20)
Type "help" for help.
This is a PostgreSQL database and likely the database installed for Ambari. Use the gpadmin account instead of postgres.
Also, if you are wanting to run TPC-DS, try this one instead which is designed for HAWQ and Greenplum. https://github.com/pivotalguru/TPC-DS
Please make sure you are calling psql which connect to hawq, instead of connecting to linux built-in postgreSQL instance.
You can run 'netstat -anp | grep 5432' to know the pid of postgres, and use 'ps -ef | grep your_pid to know the binary path, check the path is hawq.
Or you can run SQL 'SELECT VERSION();' in psql to check.
You might be connecting to ambari postgres. Check hawq settings in Ambari and use
psql -h hostname -p port -d database -U username.
Please follow the below steps .
Login to hawq master node
ps -ef |grep silent (Find out the port that hawq master is listening to )
su - gpadmin
psql ( psql should connect you to hawq gpadmin database )
if not type
psql -p portnumber -h masterhost -d database
I have PostgreSql 9.3 version installed in my ubuntu 14.04 machine. I just installed the 9.4 version as well and the port it is on is 5433(by default). When i give the command psql --version, it gives me the following:
psql (PostgreSQL) 9.4.1
So far so good! Now i am trying to change my password for my postgresql 9.4 and i gave the following command:
>>sudo -u postgres -p 5433 psql
psql (9.4.1, server 9.3.6)
Type "help" for help.
postgres=# alter user postgres with password 'password';
ALTER ROLE
postgres=# \q
Now i tried connecting it on pgadmin3 but it would give me the password authentication failure. Am i doing it right?
sudo -u postgres psql -p 5433
Your -p 5433 as you write it is treated as an option for sudo, not for psql. And you've connected to Postgres 9.3 on standard port.
Try using:
>>sudo -u postgres -p 5433 psql
psql (9.4.1, server 9.3.6)
Type "help" for help.
postgres=# \password
Enter new password:
Enter it again:
postgres=#