skip to Main Content

when i am trying to create postgres database with bash terminal on windows 11, im using below commands;

createdb 'test'

or

createdb -U postgres 'test'

and nothing happens.

enter image description here

i added the bin folder to paths in "environment variables" of windows. but it didnt solve the problem.

enter image description here

what am i doing wrong?

2

Answers


  1. 1st solution:

    • sudo su - postgres to become postgres
    • psql -c "create database demo" to create it from shell

    2nd solution:

    Just simply enter the following commands on bash:

    $ createdb -U postgres(db user) dbname

    If you set hba_config in pg for the access to the db in network type:

    $ createdb -h YOUR_IP -U postgres(db user) dbname

    Lastly, if you set password for db user, pg will ask your password to create database.

    Note: If nothing works from above, double-check your system environment variables

    Login or Signup to reply.
  2. for me I used Windows command directly, could you first try cd directly to your postgresql bin folder (I suppose createdb application must be there), then try using createdb command. If it works, there must be some wrong config with your Env variable 😀 (need restart, or just reopen your terminal)

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search