Install PostgreSQL on Ubuntu – New user and database in 3 commands

Installing PostgreSQL is trivially easy.
You just have to use the same name for linux user, database user and the database name.

It still works in 2023 with Debian 11-Bullseye, I just added 'systemctl' command to start the daemon. Very old systems start the daemon automatically, so they don't need 'systemctl' command.

$ sudo apt-get update
$ sudo apt-get -y install postgresql
$ sudo systemctl start postgresql
$ sudo -u postgres createdb tero
$ sudo -u postgres createuser tero

Use your own login name instead of “tero”.

$ psql

Yes, that’s all. You can now start writing SQL.

Posted in Uncategorized | Tagged , , , , , , , , | Comments Off on Install PostgreSQL on Ubuntu – New user and database in 3 commands

Comments are closed.