Method 1: Using SQL (psql)
Log in to your PostgreSQL server as a superuser (e.g., the
postgres user) and execute the following:- Create a User with a Password: Use the CREATE USER command. This automatically grants login privileges.
- Grant Permissions: By default, new users have no access to data. Grant them access to a specific database using the GRANT command.
- Grant Schema Access: To allow the user to see tables in a schema (like
public), run:Method 2: Using the Command LineIf you prefer not to enter the SQL shell, use the createuser utility from your terminal.- Create User with Prompt: This command will interactively ask for a password.
Important Security Notes- Changing a Password: If you need to update an existing user's password, use the ALTER USER command or the
\passwordmeta-command inpsql. - Encrypted Passwords: Modern PostgreSQL versions encrypt passwords by default (e.g., using
scram-sha-256). You can check current encryption settings in your postgresql.conf file. - GUI Tools: For a visual interface, many users manage credentials through pgAdmin.
- Create User with Prompt: This command will interactively ask for a password.


0 comments:
Post a Comment
Note: only a member of this blog may post a comment.