sudo pacman -Syu
This command updates your package database and your system.
To install PostgreSQL, use the Pacman package manager:
sudo pacman -S postgresql
This command will install the PostgreSQL server and client on your system.
Before using PostgreSQL, you need to set up the database cluster, which is a group of databases managed by a PostgreSQL server.
sudo -iu postgres
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
--locale $LANG
: Sets the language settings for the database.
-E UTF8
: Makes sure the database uses UTF-8 encoding.
-D '/var/lib/postgres/data'
: Chooses where the data will be stored.
Now, start the PostgreSQL service and enable it to start on boot automatically:
sudo systemctl start postgresql
sudo systemctl enable postgresql
These commands start the PostgreSQL service, so make sure it starts automatically whenever your system boots.
To manage databases and users, switch to the PostgreSQL user:
sudo -iu postgres
Create a new PostgreSQL user with:
createuser --interactive
You'll be prompted to enter the username and decide whether the new user should be a superuser.
With your PostgreSQL user set up, you can now create a database:
createdb your-database-name
To start working with your databases, access the PostgreSQL command-line interface (CLI) with:
psql
Or, connect directly to a specific database:
psql mydatabase
When you're done, you can exit the PostgreSQL shell by typing:
\q
Join Ashish on Peerlist!
Join amazing folks like Ashish and thousands of other people in tech.
Create ProfileJoin with Ashish’s personal invite link.
0
7
0