psql command not found - Amazon Linux

Page content

How to Install psql Command on Amazon Linux

Introduction

The psql command is a command-line interface for interacting with PostgreSQL databases. If you are using Amazon Linux and encounter the “psql command not found” error, you will need to install the PostgreSQL client tools to use psql.

Installation Steps

  1. Update the package repository:

    sudo yum update
    
  2. Install the PostgreSQL client tools:

    sudo yum install postgresql
    
  3. Verify the installation by checking the psql command:

    psql --version
    

Solution for Incompatible Commands

In case the above commands are not compatible with Amazon Linux, you can try the following alternative installation method:

  1. Add the PostgreSQL repository to your system:

    sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
  2. Install the PostgreSQL client tools:

    sudo yum install postgresql11
    
  3. Verify the installation by checking the psql command:

    psql --version
    

Conclusion

By following the steps outlined in this tutorial, you should now have successfully installed the psql command on your Amazon Linux system. You can now use psql to interact with PostgreSQL databases from the command line.