psql: FATAL: role "root" does not exist when creating database from fabric explorer's sql file - postgresql

I meet error psql: FATAL: role "root" does not exist when running ./createdb.sh from https://github.com/hyperledger/blockchain-explorer. I am trying to run the blockchain explorer on Centos.

I think the last version broke something, or makes it incompatible with some of the tooling around.
Try reverting to the prev docker images:
hyperledger/explorer-db:0.3.8
hyperledger/explorer:0.3.8
That did the trick for me.

Similar error for me "psql: FATAL: role "postgres" does not exist" when running the createdb.sh script. I am trying to install on ubuntu.
I fixed it by running the following command before :
/home/linuxbrew/.linuxbrew/Cellar/postgresql/11.4/bin$ createuser -s postgres
than run the createdb.sh script WITHOUT using sudo.
Hope this can help somebody.

You should specify the DB user while running the script.
Modify explorerconfig.json under blockchain-explorer/app to include the properties of the connection to DB like "host", "port", "database", "username" and "password".
Please refer to this readme from their github repo - https://github.com/hyperledger/blockchain-explorer/blob/master/README.md#Database-Setup

Related

creating a postgresql database back end for a new Label Studio project

I am creating a local Label Studio server to host images to annotate in our office. I would like the database back end to be postgresql and not sqlite and be located in a particular directory, not the default and not the same as the 'data-dir'. I have got a test server working across the network with various machines annotating images on the server, but the backend was sqlite for this test.
Everything I've tried to get a postgresql backend db has failed for various reasons. Some commands result in a sqlite db (occasionally with the name 'postgresql') located in my required directory; others create postgres/pyscopg2 errors but I think they're up a garden path.
The host machine is running Ubuntu 20.04 LTS. And serves another postgresql db over the network using other APIs. Postgresql version running is 12.9.
I have created a conda environment and pip installed Label Studio as the documentation suggested.
Here's what I've tried:
Start the conda environment. Follow instructions to assign environment variables from https://labelstud.io/guide/storedata.html#PostgreSQL-database which at time of writing is:
DJANGO_DB=default
POSTGRE_NAME=postgres
POSTGRE_USER=postgres
POSTGRE_PASSWORD=
POSTGRE_PORT=5432
POSTGRE_HOST=db
Then a few variations on the start command (I didn't include the backslashes, just put here for readability/comparability):
label-studio start --init \
-db postgresql \
--database /path/to/label-studio/databases/newdb \
--data-dir /path/to/label-studio/media_dirs/test_proj
result: db is where expected, but:
file newdb
gives "newdb: SQLite 3.x database, last written using SQLite version 3038002"
label-studio start --init \
--database /path/to/label-studio/databases/newdb \
-db postgresql \
--data-dir /path/to/label-studio/media_dirs/test_proj
result: a db at specified path named 'postgresql' and still an sqlite db. This seems to mirror the mistake mentioned at: https://github.com/heartexlabs/label-studio/issues/1660
I have also tried the above two commands with the '--init' argument omitted with same results.
Then I tried adding something on the front of the command suggested at the same link above:
DJANGO_DB=default label-studio start \
--database /path/to/label-studio/databases/newdb \
--data-dir /path/to/label-studio/media_dirs/test_proj
result: psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
DJANGO_DB=default POSTGRE_PASSWORD= label-studio start \
--database /path/to/label-studio/databases/newdb \
--data-dir /path/to/label-studio/media_dirs/test_proj
result: psycopg2.OperationalError: fe_sendauth: no password supplied
Any help and resolution would be highly appreciated.
Also, I can't tag this with 'label-studio' because I'm not quite at the required reputation to create a new tag, so if anyone who can feels like doing so, pleaseandthankyou!
Your last option was closer than all the others. Have you tried to run LS using this:
DJANGO_DB=default POSTGRE_NAME=<postgres_name> POSTGRE_USER=<postgres_user> POSTGRE_PASSWORD=<password> POSTGRE_PORT=<db_port> POSTGRE_HOST=<db_host> label-studio
Sure, you have to run postgres service by yourself, configure it properly, create the DB <postgres_name>, the user <postgres_user> and set the password <password>, grant access rights to this user. Also don't forget to specify <db_host> (localhost?), <db_port> (5432?)

Create user on Postgres 9.5 using FreeBSD and Vagrant

I am trying to create a user in Postgresql 9.5 on FreeBSD 11. I am also trying to automate the whole thing with Vagrant and I have almost succeeded except for the creation of the user. I am using the createuser command with a password, and with that, I have attempted to use expect command in order to send the password to the prompt but I continue to receive the following error message:
"default: createdb: could not connect to database template1: FATAL: role "root" does not exist"
Here is the code sample that I am using:
# Create the database and the user
PASS=password
expect << EOF
spawn createuser -sdrP capstone
expect "Enter password for new role:"
send "${PASS}\r"
expect "Enter it again:"
send "${PASS}\r"
expect eof;
EOF
I am not too sure what else to try in regards to overcome this error, any help would be appreciated.
Do not run this script as root.
By default user "pgsql" has the permissions.
Switch to user:
su -l pgsql
Then run your expect script.

Running PGAdmin after Silent installation, what is the login?

I started an installation of Postgres in unatended mode with the commandline:
postgresql-9.5.2-1-windows-x64-x64.exe --unattendedmodeui minimal --mode unattended --superpassword "password" --servicename "postgreSQL"
--servicepassword "password" --serverport 5432
After the installation is finished i want to login to the database with pgadmin. i tried with "password" but i get the error:
fatal password authentication failed for user postgres
so what are my login data for the installed database?
Thanks a lot
Marcel
If you don't know the password you have to change the pg_hba.conf file that contains all the authentication information.
You can read about how it works here:
http://www.postgresql.org/docs/devel/static/auth-pg-hba-conf.html
I suggest you to create a backup of the original file first and to reboot the server after changes.
I was facing the same issue. It looked like there was a conflict with previous installations of Postgres.
I could login using the password specified by --superpassword after cleaning all Postgres-related folders in program files as well as in custom install locations.
A professional approach would be running your installer on a clean system or a VM.

could not start pgAgent due to log on failure

I wanted to install pgAgent service on windows. Though it installs alright using the following command:
C:\Program Files (x86)\pgAdmin III\1.14>pgagent.exe INSTALL pgAgent -l2 -u postgres hostaddr=localhost port=5432 dbname=postgres user=postgres
the service does not start giving an error: Windows could not start pgAgent service on the local computer. Error 1069: The service did not start due to a logon failure.
The password is being provided using pgpass.conf file. The same password is being used by pgAdmin to logon to databases.
I have even tried by providing same password (as pgpass.conf) using -p option on the command line itself. It did not work either but error is different. On command line it says service could not be started. Service reported no error . However when I see logs in Control Panel/EventViewer following warning is shown:
Couldn't create the primary connection (attempt 10): fe_sendauth: no password supplied
and then an error:
Stopping pgAgent: Couldn't establish the primary connection with the database server.
If it could help, I downloaded pgAgent separately and placed pgAgent.exe in pgAdmin III/1.14 folder where libpq.dll also resides. I am using PostgreSQL 9.0, pgAdmin 1.14 and pgAgent 3.0.0
Can somebody please help me with this?
Go to pgAgent installation folder on windows and execute
C:\Program Files (x86)\pgAgent\bin>pgagent REMOVE pgAgent
This will remove the existing misconfigured windows service
then reinstall the service in the following way giving the password credentials properly. The first -u gives the postgres user created on windows and the second username in the connection string is the db username.
After doing the below start the service and check the Event Viewer if you still see the error.
C:\Program Files (x86)\pgAgent\bin>pgagent --help
Usage:
pgagent REMOVE <serviceName>
pgagent INSTALL <serviceName> [options] <connect-string>
pgagent DEBUG [options] <connect-string>
options:
-u <user or DOMAIN\user>
-p <password>
-d <displayname>
-t <poll time interval in seconds (default 10)>
-r <retry period after connection abort in seconds (>=10, default 30)>
-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>
C:\Program Files (x86)\pgAgent\bin>pgagent INSTALL pgAgent -u postgres -p admin
-l 2 hostaddr=127.0.0.1 port=5433 user=postgres dbname=first password=admin
ok guys, i am able to solve the issue, by reinstalling PostgreSQL and then installing pgAgent with StackBuilder.

Cannot start postgresql properly

I cannot "service postgresql start" by root:
Startup Log: /usr/bin/postmaster: error while loading shared
libraries: libz.so.1: failed to map segment from shared object:
Permission denied
I cannot "service postgresql start" by postgres:
Startup Log:runuser: cannot set groups: Operation not permitted
But I can start it by postgres user with command:
postmaster -D /usr/local/pgsql/data
Why?
When I installed, I used
initdb -D /usr/local/pgsql/data
not
service postgresql initdb
So I afterwards changed init.d/postgresql script with the new path. Is this causing problem?
Caused for me by creating the DB with
/etc/init.d/postgresql-9.3 initdb
Recreating with
service postgresql-9.3 initdb
solved the issue.
As Craig said this is either a file permission issue or a selinux issue. If it is a file permissions issu, that is easy enough to fix (give read/execute perms).
If it is an selinux issue your best option is to run audit2allow to identify the problem and ensure that selinux is configured to allow the correct access.