On Postgres-XC start getting sudo: unknown user: postgres sudo: unable to initialize policy plugin? - linux

Installed Postgres-XC
$>sudo apt-get install postgres-xc
then
$ postgres -V
postgres (PostgreSQL) 9.2.4
after this I tried to start the Postgres server using following methods.
method 1
$>sudo postgres --coordinator -D DN2
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
method2
$ sudo -i -u postgres
sudo: unknown user: postgres
sudo: unable to initialize policy plugin
and installed pgadmin3 also from there I want to connect Postgres server .
what is the correct way to start the Postgres-XC server?
Is the above procedure correct? if yes what is wrong with it?

To install Postgres's, the best way to is using enterpriseDB.
To see some downloader installer section from the below URL.
https://www.postgresql.org/download/linux/ubuntu/
To download the Postgres
http://www.enterprisedb.com/products-services-training/pgdownload#linux
To install the Postgres
http://tutorialforlinux.com/2014/02/20/how-to-install-latest-postgresql-9-x-on-linux-mint-16-petra-3264bit-linux-easy-guide/

Related

Reposting - Error: Ident authentication failed for user

I feel like the foot traffic is slow on Unix&Linux, so I'm also posting this question here:
I have a Postgres installed in CentOS, along with Node and React with NGINX. I've left alone my Unix postgres account to be without a password as recommended here. I've also written migrations with postgrator, which creates a table as blog_user in the blog_database.
My blog_user has LOGIN attribute with encrypted password, and the database blog_database is owned by postgres.
When I run my migrations in CentOS, I get this message
[joseph#vultr backend]$ yarn run migrate
yarn run v1.17.3
$ postgrator --config postgrator-config.js
[2:41:39 AM] table schemaversion does not exist - creating it.
[2:41:39 AM] version of database is: 0
[2:41:39 AM] migrating up to 2
Error: Ident authentication failed for user "blog_user"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
When attempting to change peer to md5 for all, I am required to put in a password for postgres
-bash-4.2$ vim /var/lib/pgsql/11/data/pg_hba.conf
-bash-4.2$ sudo systemctl restart postgresql.service
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for postgres:
Sorry, try again.
Executing the restart command as root leads to this message
[root#vultr ~]# vim /var/lib/pgsql/11/data/pg_hba.conf
[root#vultr ~]# systemctl restart postgresql.service
Failed to restart postgresql.service: Unit not found.
I'm not sure what I need to do to solve this.
Use trust authentication for local connections unless you have untrusted operating system users on the machine.
The PostgreSQL service probably has a different name. Try
systemctl status | grep postgres

Postgresql user "postgres" requires password in order to create db

I am running centOS 7 and trying to create a postgresql database
I entered to following to install and initiate database
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
sudo yum install postgresql11
sudo yum install postgresql11-server
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
so after this i try to create a database by entering
sudo createdb mydb
receive:
createdb: could not connect to database template1: FATAL: role "root" does not exist
so now i realize i need to be on the postgre user
and cannot create a db with this command:
sudo -u postgres createdb mydb
Recieve:
could not change directory to "/home/<user>": Permission denied
I am able to get the postgre prompt by entering the following
sudo -u postgres -i
psql
but when i enter sudo -u postgres -1 i get a new bash prompt -bash-4.2$
when i try to create a database in this prompt with sudo createdb mydb it asks for a password for postgres and can't go on from there,
what is this password? i read that by default it shouldn't
Did you try
sudo -i -u postgres
psql CREATE DATABASE yourbase;
\c yourbase ?

Unable to connect to server: postgresql on ubuntu in windows subsystem for linux

I'm using WSL with an ubuntu 18.04 distribution, in the bash I hit sudo -u postgres psql
I get the following error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?
Then I tried other postgres operations like: sudo -u createdb mydb
only to get the same error.
Please advise.
When running PostgreSQL on Ubuntu in Windows Subsystem for Linux, you may have to manually start the db server before you can connect. Use the command below to start your db server and then try connecting.
sudo service postgresql start
OR
sudo /etc/init.d/postgresql start
You can also check the status of the db server with:
sudo service postgresql status

PostgreSQL 9.4.10 - CREATE DATABASE throws ERROR: permission denied to create database

Postgres version: PostgreSQL 9.4.10 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
Postgres server is installed using Vagrant with user account created at the time the VM was provisioned.
Steps I did to login and use psql command:
ssh to the server
sudo su - postgres
PGUSER=username PGPASSWORD=password psql -h localhost myapp
Than I issue the command in psql:
myapp=> CREATE DATABASE myDB;
ERROR: permission denied to create database
myapp=>
Can anyone tell me what do I miss? thanks

Running Yesod in Cloud9

These are the steps I used to run a Yesod scaffold in Cloud9. The whole process took a few hours and I had to upgrade memory and disk (do this before proceeding):
Installing Stack
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442
(Ubuntu 14.04 (amd64)):
echo 'deb http://download.fpcomplete.com/ubuntu trusty main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update && sudo apt-get install stack -y
Status: running $ stack from the command line works as expected
Yesod Template Quickstart
Create a new scaffolded site:
stack new yesodOnC9 yesod-postgres && cd yesodOnC9
Install the yesod command line tool:
stack build yesod-bin cabal-install --install-ghc
Build libraries:
stack build
Create PostgreSQL Database in C9
Start the PostgreSQL service
$ sudo service postgresql start
Connect to the service
$ sudo sudo -u postgres psql
Create a PostgreSQL database (from inside psql, at last step)
postgres=# CREATE DATABASE "yesodDB";
Create a test PostgreSQL database
postgres=# CREATE DATABASE "yesodDB_test"
Set Password for Postgres User
postgres-# \password postgres
Enter new password: MYPASSWORD
Result:
user: postgres
password: MYPASSWORD
Configure Yesod to Database
Open config/settings.yml
Change database user to:
user: "_env:PGUSER:postgres"
Change database password to:
password: "_env:PGPASS:MYPASSWORD"
Change database database to:
database: "_env:PGDATABASE:yesodDB"
Close settings.yml and open test-settings.yml
Change database database to:
database: yesodDB_test
Launch devel server:
stack exec -- yesod devel -b $IP -p $PORT
Result: Successful, Running Scaffold
If you leave your workspace, you will have to restart the PostgreSQL service with: $ sudo service postgresql start when you return.
Did you configure Postgres to accept TCP connections as indicated by the error message? Your installation of Yesod seems ok, but Yesod reads the DB to make a migration at start time so it needs a connection to your DB.

Resources