How to create super user in Postgres - postgresql

I am new to Saleor and I followed all the step in the documentation. However I can't seem to create a new user. I have install PostgreSQL 11 using a .dmg file downloaded from the official website.
Every time I run createuser --superuser --pwprompt <username> I get bash: createuser: command not found.
If I try to install PostgreSQL with "brew install Postgres" and then run createuser --superuser --pwprompt <username>, I get asked for password twice for the new role then a third time which I have tried to many time to enter with no success. I get the error FATAL: password authentication failed for user <terminal username>.
I'm using VS code

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?)

postgres is not in the sudoers file. This incident will be reported

If the error occurs when trying to create PostgreSql Role This error occurs because you are inside the postgresql.
You need to change to root user, for that you need to type in the terminal,
su root
Next run the command,
sudo -u postgres createuser --interactive
Your question is hard to follow, as it reads like you are just quoting someone else, but it isn't clear who or why.
The way this usually happens to me is that initially I am logged in as a user who does have sudo powers (my normal daily user account), but then I change into "postgres" Linux user by executing sudo su - postgres. But once there, I then try to execute some sudo command, but since logged in as postgres and postgres does not have sudo powers, I get this error. I fix the error by exiting the shell which is logged in as postgres, and so dropping back to my regular account, before repeating the sudo attempt.

PostgreSQL on Mac doesn't recognize users password

I have tried numerous suggestions from other posts and SO questions but none seem to do the trick. I just installed PostgreSQL with brew install, then ran the initdb command. The output said the user would be used for the DB, however, the user is always displayed as the mac user. What might I be missing?
output from console:
createdb: could not connect to database template1: FATAL: password authentication failed for user "macuser"
Users-MBP:~ macuser$
Just delete installed postgresql by doing below.
Remove previous versions of PostgreSQL
brew uninstall --force postgresql
Delete all Files of Postgres
rm -rf /usr/local/var/postgres
Download macOS packages from Postgresql and install it.
https://www.postgresql.org/download/macosx/
Default user will be postgres and password field will be required when install

After installing postgres 9.4 on fedora 20, couldn't launch psql

I have installed postgres 9.4 on fedora 20.
i have followed the steps through the link below
https://wiki.postgresql.org/wiki/YUM_Installation
I have started the server using the command
service postgresql-9.4 initdb
Then I set the auto start using the command
chkconfig postgresql-9.4 on
I am able to connect with Data base server via pg admin
but I am not able to connect with postgres DB server or SQL command line via terminal
If I enter psql for postgres/or any user, it says command not found.
can any one please help me on this.
You need to go to the installation bin directory and use './ExecutableFile' to run when logged in with postgres user.
So, use ./psql when you are in bin directory.
Or you can use "export PATH=path/to/bin/" to avoid using './'

mapnik gis authentication error during boot

I am using tilelite to serve up maps. I need it to run at the time the server is started. I have built a script that runs the following command at startup:
/usr/local/bin/liteserv.py /home/Uname/bin/mapnik/my_osm.xml --caching --debug=False
The process is failing with:
FATAL: Ident authentication failed for user "user_name" (encountered during parsing of layer 'leisure')
According to this page:
http://wiki.openstreetmap.org/wiki/Mapnik#Authentication_failed
I ran the following command:
./generate_xml.py osm.xml my_osm.xml --accept-none --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
Now I get:
RuntimeError: PSQL error:
FATAL: Ident authentication failed for user "root" (encountered during parsing of layer 'leisure')
I am really new to postgres so could someone give me some very simple insructions on how to fix this.
If you call ./generate_xml.py --help you will see the various options. One of them is --user. If you do not supply it and also pass --accept-none then no specific user will be written into the Mapnik XML, which means that when Mapnik attempts to connect to the postgres database the current user will be used. So, if you run that script as root, 'root' will be used.
So, you need to either run that script as a unix user that can connect to postgres, or you need to go back and regenerate the XML and embed the name of a user that can connect to postgres. The latter is likely easier. Here is what I would do:
Assuming your normal unix use is named 'heman' do:
$ sudo su postgres
$ createuser heman # make superuser
$ exit
$ ./generate_xml.py osm.xml --accept-none --user heman --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
$ liteserv.py osm.xml --caching --debug=False
More details on postgres and how to enable "trust" so that you can connect as the "postgres" user here: http://dbsgeo.com/foss4g2010/html/troubleshooting.html#troubleshooting-postgresql-connections