Home / MySQL

Install PostgreSQL database on WSL Ubuntu 18.04

Posted on:2023-04-18 Views:2198 Words:257

Install

sudo apt update
sudo apt install postgresql postgresql-contrib

View the version number

> psql --version
psql (PostgreSQL) 10.23 (Ubuntu 10.23-0ubuntu0.18.04.1)

Currently, the latest PostgreSQL version is 15, which is too far behind…

Start postgresql service in Windows WSL

Because systemd is not supported in WSL1, start the service using:

sudo service postgresql start

If it is on a normal server, you can

sudo systemctl start postgresql.service

reboot

sudo service postgresql restart

Enter the command line

$ sudo -i -u postgres
$ psql
psql (10.23 (Ubuntu 10.23-0ubuntu0.18.04.1))
Type "help" for help.

postgres=#

MySQL vs PostgreSQL

  • Data Types: PostgreSQL supports a wider variety of data types, including arrays, hstore, and JSONB. MySQL has fewer data types and is not as flexible.
  • ACID Compliance: PostgreSQL follows the ACID (Atomicity, Consistency, Isolation, and Durability) principles strictly, making it a good choice for applications that need transactional integrity. MySQL has weaker support for these principles, but this can be improved by using the InnoDB storage engine.
  • Scalability: Both databases are scalable, but MySQL typically performs better under high read/write loads. However, PostgreSQL is better suited for complex queries and large amounts of data.
  • Security: PostgreSQL has more advanced security features than MySQL, such as row-level security, which allows specific rows in a table to be restricted from certain users.
  • Licensing: PostgreSQL is released under the PostgreSQL License, while MySQL is available under the GPL or commercial licenses.