Create PostgreSQL user from command line
Open terminal and execute the following command. Substitute "username" with your actual username.
createuser usernameIf you want to specify password for the user, execute the command with "-P" argument. Password will be prompted right away.
createuser -P usernameTo create user on a specific database connection, supply connection details using connnection options. Admin password will be prompted, you don't need to specify it in the command options.
createuser --host=188.8.131.52 --port=5432 --username=admin_user --password username
Create user with SQL commandLog into Postgres using command line tool "psql" or any database administration software. The SQL syntax is similar to the one described above. To create a new user execute the following SQL statement. Substitute "username" with your actual username.
CREATE USER usernameTo specify password in SQL statement use the following syntax. Substitute "secret" with your a strong password.
CREATE USER username WITH PASSWORD 'secret'That's it - now you can log in with the new user. To learn more about PostgreSQL checkout Beginning Databases with PostgreSQL: From Novice to Professional.