PostgreSQL is one of the most popular database systems available today. In this guide, we’ll walk you through how to install Postgres on Linux.
You can install Postgres by following the commands corresponding to your Linux distribution:
sudo apt update sudo apt install postgresql postgresql-contrib
sudo pacman -S postgresql sudo -iu postgres initdb -D /var/lib/postgres/data
sudo yum -y update sudo systemctl reboot sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo dnf -qy module disable postgresql sudo dnf install postgresql13 postgresql13-server sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Now, we have to set a root password for our Postgres server by running
psql as the newly-created ‘postgres’ user:
$ sudo -u postgres psql postgres=# ALTER USER postgres with password ‘myPassword’;
Now, let’s connect! Open Arctype, press ‘Add New Connection’, and enter your connection information. For now, we’ll use the
postgres user with the password set during installation and the database
Press Test Connection to confirm that all of your information is correct and then save!
Now that you have connected, you should make a few changes to improve the security of your database. The first is to create a new database that is separate from the mysql informational database you are currently connected to. Click New Query and run the following command:
CREATE DATABASE myDB
Next, you should create a new user:
CREATE USER myUser WITH PASSWORD ‘myPassword’
And finally, you’ll need to grant this user full permissions on your database:
GRANT ALL PRIVILEGES ON myDB TO myUser
Go back to the settings menu in your SQL client and switch to this new user and database. You’re all ready to start writing queries!