9951 explained code solutions for 126 technologies


postgresqlHow do I install PostgreSQL?


  1. Download PostgreSQL from PostgreSQL website.
  2. Install the downloaded package with the command: sudo apt-get install postgresql-12.
  3. After installation, create a user and database with the following commands:
sudo -u postgres createuser -s <username>
sudo -u postgres createdb <dbname>
  1. Connect to the database with the command: psql -U <username> -d <dbname>.
  2. Create tables and add data to the database with SQL commands.
  3. To stop the database, use the command: sudo service postgresql stop.
  4. To start the database, use the command: sudo service postgresql start.

Edit this code on GitHub