0

There is a manual for configuring PostgreSQL on Windows with these commands:

C:\"Program Files"\PostgreSQL\12\bin\createuser.exe --username=postgres --superuser --pwprompt saleor

C:\"Program Files"\PostgreSQL\12\bin\createdb.exe --username=postgres --owner=saleor saleor

I'm going to do the same on Linux, but I'm not sure how.

I know that I have to do:

> sudo su postgres
> psql 

psql (13.3)
Type "help" for help.

postgres=# 

But I'm not sure what to do next. I appreciate any help.

4
  • Search for connect to database using psql - maybe \c saleor?
    – Vérace
    May 28, 2021 at 11:13
  • 2
    An linux you would use createuser instead of createuser.exe and createdb instead of createdb.exe - but outside of psql. Or inside psql use the SQL commands create user saleor and create database saleor owner saleor. But that tutorial is pretty bad because it recommends to create that user as a superuser which is a really bad idea. A superuser should not be used for regular applications. Applications that require that shouldn't be used
    – user1822
    May 28, 2021 at 11:47
  • That's right =) First running sudo su postgres an then running createuser --username=postgres --superuser --pwprompt saleor seems to be fine :)
    – Megidd
    May 28, 2021 at 11:48
  • @a_horse_with_no_name Can you post your comment as an answer so that this question can be marked as solved :)
    – Megidd
    May 28, 2021 at 11:49

2 Answers 2

0

On a 32-bit openSUSE Tumbleweed with PostgreSQL 13 installed. Just run:

> sudo su postgres
> createuser --username=postgres --superuser --pwprompt saleor
> createdb --username=postgres --owner=saleor saleor

If the user already exists, it can be deleted by:

> sudo su postgres
> dropuser --username=postgres saleor

To see a list of users and databases, just run:

> sudo su postgres
> psql
# \du
# \l
# \q
-2

Execution files of the postgres database in linux should be found in installation path as well as windows.Use:

createdb [options...] databaseName

If you used below command and get command not found error use this command:

/usr/lib/postgresql/<version>/bin/createdb [options...] databaseName 

Where is your postgresql version and options are same options you use in windows.

2
  • Does this add anything over what currently exists? May 12 at 12:45
  • @MichaelGreen unfortunately no
    – mahdi
    May 13 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.