Setting up a PostgreSQL database#
This part is only required if you are going to be setting up a server (i.e., the main database). If you are setting up only the client, you can skip this step.
On Debian-based systems (e.g., Ubuntu), you can install PostgreSQL with:
sudo apt-get update sudo apt-get install postgresql postgresql-contrib
For other systems, please check the original PostgreSQL website for instructions.
In your terminal, use brew to install the PostgreSQL database:
brew install postgresql
Starting the PostgreSQL database#
You can start the PostgreSQL service by running:
sudo systemctl enable postgresql sudo systemctl start postgresql
If you do not have
sudo priviledges in your system, you can start the database locally by following the instructions on PostgreSQL.
To start the PostgreSQL service, run:
brew services start postgresql
Alternatively, to start PostgreSQL manually, run:
pg_ctl -D /usr/local/var/postgres start
Creating a new PostgreSQL database#
With the PostgreSQL database installed, you can create a new database to store the jobs and results of the calculations. To do so, follow these steps:
In your terminal, run the following command to create a new database with the name
mydb(replace by name of your choice):
Connect to the newly created database using psql:
By default, PostgreSQL uses the current system user as the database user and does not require a password for local connections. To set a password for the database user, run the following SQL command within
your_passwordwith the desired password:
ALTER USER current_user WITH PASSWORD 'your_password';
After setting the password, update the PostgreSQL configuration file (
pg_hba.conf) to require a password for connections. Find the line that starts with local or host, followed by the database name, user, and connection type (e.g., trust). Change the connection type to md5 or password to require a password for authentication.
Finally, to retrieve the current database name, user, and host, run the following SQL command within
SELECT current_database(), current_user, inet_server_addr();
Now you have initialized a PostgreSQL database and retrieved the credentials (username, password, and database name) to access the database. Save these credentials, as we will use them later to access the database.