How to switch users in psql?

To switch users in psql, you can use the \c command followed by the database name and the new user you want to connect as. Here’s the syntax:

\c database_name new_user

For example, if you want to switch to the mydatabase database as the user newuser, you would execute:

\c mydatabase newuser

If you are already connected to a database and want to switch users without specifying a database, you can simply use:

\c database_name

You will be prompted to enter the password for the new user if required.

Keep in mind that you need to have the necessary permissions to connect as the new user.

0 Comments

no data
Be the first to share your comment!