'How to create a new postgresql database via ubuntu shell

I’m doing;

createdb -O dan -h 127.0.1.1 -p 5432 -U dan -w testdb

but it throws me:

fe_sendauth: no password supplied

Then I tried to remove -w and it asks for a password but no one password that I type matches:

password authentication failed for user "dan"

Also it should be a bash script, so I can`t enter psql (I guess). Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source