Skip to content
Menu
i do, therefore i am
  • Home
  • Blog
  • Contact us
i do, therefore i am
February 13, 2022November 7, 2022

Creating a user in Postgres

Users can be created either by using the command createuser or one the SQL statements CREATE ROLE or CREATE USER.

The createuser command, which is a wrapper to the SQL Command CREATE ROLE, has the added advantage of providing for the interactive creation users by answering a series of questions. To run createuser interactively you use the –interactive command line switch.

The following code snippet will create a user in interactive mode by prompting for details to the user.

createuser --interactive --pwprompt

To create a user non interactively you can use the command createuser as follows.

create user user_name with encrypted password 'mypassword';

More info on createuser here:

https://www.postgresql.org/docs/current/app-createuser.html

Users can also be created by SQL:

CREATE USER 'username' PASSWORD 'password';
CREATE ROLE 'username' PASSWORD 'password';

More on CREATE USER and CREATE ROLE here:

https://www.postgresql.org/docs/current/sql-createuser.html

https://www.postgresql.org/docs/9.3/sql-createrole.html

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • vim as Hex-Editor
  • installing pico-sdk in wsl
  • A WordPress theme from scratch 5
  • A WordPress theme from scratch 4
  • Serial Port Windows

Recent Comments

    Archives

    • May 2023
    • January 2023
    • November 2022
    • October 2022
    • September 2022
    • May 2022
    • April 2022
    • March 2022
    • February 2022
    • January 2021

    Categories

    • Fortran
    • linux
    • Postgresql
    • Programming
    • Python
    • Tools, tips and tricks
    • Wordpress

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Postgres

    • postgres-docs

    Python

    • data model
    • the standard library
    • python tips
    • import system
    • asyncio
    • built-in functions

    Open_VMS

    • lexicals at marc’s place
    • documentation and manuals
    • system services
    • rms services reference
    ©2025 i do, therefore i am | Powered by WordPress and Superb Themes!