How To Install Psql On Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian And MacOS?
Install psql
-
Debian
apt-get install postgresql-client-9.1Click to copy -
Ubuntu
apt-get install postgresql-client-9.3Click to copy -
Alpine OS
apk add postgresqlClick to copy -
Arch Linux
pacman -S postgresql-old-upgradeClick to copy -
Kali Linux
apt-get install postgresql-client-11Click to copy -
CentOS
yum install postgresqlClick to copy -
Fedora
dnf install postgresqlClick to copy -
Raspbian
apt-get install postgresql-client-9.5Click to copy -
macOS
brew install postgresqlClick to copy
PostgreSQL command-line client.
How to use psql?
Below are few example commands for psql that you can use in the terminal.
Connect to database. It connects to localhost using default port 5432 with default user as currently logged in user:psql databaseClick to copyConnect to database on given server host running on given port with given username, without a password prompt:psql -h host -p port -U username databaseClick to copyConnect to database; user will be prompted for password:psql -h host -p port -U username -W databaseClick to copyExecute a single SQL query or PostgreSQL command on the given database (useful in shell scripts):psql -c 'query' databaseClick to copyExecute commands from a file on the given database:psql database -f file.sqlClick to copy
Installation of latest psql command is available for Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian and macOS. You can copy the command for your OS from above and paste it into your terminal. Once you run the command it will download the 2026 latest package from the repository and install it in your computer/server.




