Created 02-22-2018 03:43 AM
I installed Ambari as root user with its default/embedded Postgresql db and would like to use it to create hive and oozie databases. Ambari was installed successfully and postgress is running. But when running the following command to create hive database as root user
echo "CREATE DATABASE hive;" | psql -U postgres
I get the following error:
psql: FATAL: Peer authentication failed for user "postgres"
Here is /var/lib/pgsql/data/pg_hba.conf
local all postgres peer # IPv4 local connections: host all postgres 127.0.0.1/32 ident local all ambari,mapred md5 host all ambari,mapred 0.0.0.0/0 md5 host all ambari,mapred ::/0 md5
Created 02-22-2018 04:20 AM
Please try to do "su - postgres" first.
Example:
# su - postgres Last login: Thu Feb 22 00:52:08 UTC 2018 on pts/0 $ echo "CREATE DATABASE hive;" | psql -U postgres CREATE DATABASE
.
Created 02-22-2018 10:42 PM
Thank you, Jay, for the prompt response. I used the following cmd to to run from script and it worked
cmd="echo ${sql}|psql -U postgres" su - postgres -c "$cmd"
Created 02-22-2018 10:47 PM
Good to know your issue is resolved.
The actual cause of the following error can be solved by using "su - postgres". after that you can execute whatever command you want. The Key to fix the following error us to use "su - postgres"
psql: FATAL: Peer authentication failed for user "postgres"