@emie
To install PostgreSQL on Ubuntu, you can follow these steps:
- First, update the package list by running the following command:
- Next, install the PostgreSQL server and client packages by running the following command:
1
|
sudo apt install postgresql postgresql-contrib
|
- After the installation is complete, the PostgreSQL service will be started automatically. You can check the status of the service by running the following command:
1
|
systemctl status postgresql
|
- To create a new PostgreSQL database and user, you can follow these steps:
- Connect to the PostgreSQL shell by running the following command:
- Once you are in the PostgreSQL shell, you can create a new database by running the following command:
1
|
CREATE DATABASE mydatabase;
|
- To create a new user and grant them access to the database, you can run the following commands:
1
2
|
CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;
|
- To exit the PostgreSQL shell, you can type q and press Enter.
I hope this helps! Let me know if you have any questions.