Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to log in to postgresql database on linux?


Asked by Titus Hickman on Dec 09, 2021 Linux



The server used in this section is running Ubuntu Linux 18.10. To Log into your user account in the database: If you are the database administrator and need access to the root PostgreSQL user account, the method is slightly different.
Likewise,
Connect to the database: /usr/bin/psql bedrock. Execute command as Linux user postgres. You will now be at the PostgreSQL command line prompt. [prompt]$ psql - or "psql bedrock". Welcome to psql, the PostgreSQL interactive terminal.
And, To Log into your user account in the database: psql -U <postgre username> -d <dbname> Logging in to root PostgreSQL user account If you are the database administrator and need access to the root PostgreSQL user account, the method is slightly different.
In respect to this,
Installing PostgreSQL creates a default database and user account, both called ‘postgres.’. To log into the ‘postgres’ user account type the following command in the terminal: sudo –i –u postgres. This example shows the command in a Debian-based distribution, Ubuntu.
Subsequently,
To create the user group postgres on my Linux server, I will type groupadd postgres at the command line. Next, to create the user and put it into this group, I will issue the command useradd postgres –g postgres. We need to do a couple of additional things before we actually begin installing PostgreSQL.