Fedora Server System Administrators Cheat Sheet: PostgreSQL
Peter Boy
Версія F35-F43
Last review: 2025-12-04
The Fedora System Administrator’s Cheat Sheet series compiles typical, frequently used instructions for various application programs, most of which can be used with minor modifications via copy&paste. They also contain direct links to the relevant sections of the upstream documentation.
Basic Commands
- Get administrative access to a postgresql database and get a postgres terminal prompt
-
[...]# sudo -i -u postgres psql psql (18.1) Type "help" for help. postgres=#
- List all databases
-
postgres=# \l
- Connect to a database
-
postgres=# \c <database_name_from_above_list>
- List all tables in the database connected to
-
postgres=# \dt
- List all users / roles
-
postgres=# \du
- Create a new user / role
-
postgres=# CREATE USER new_user_name WITH PASSWORD 'password';
- Change password of a user / role
-
postgres=# ALTER USER user_name WITH PASSWORD 'new_password';
Want to help? Learn how to contribute to Fedora Docs ›