DEV Community

Moiz Ibrar
Moiz Ibrar

Posted on • Updated on

Initializing and Creating a Testing Database in PostgreSQL 12.0 with Age Part 2

Testing:

In the previous article we learned how to install PostgreSQL and age from source. Part 1 here.

Creating and testing of database cluster.

Database initialization:

Now we will initialize our database cluster.

cd postgresql-12.0
which psql
ls /usr/local/pgsql/bin/
export PATH=/usr/local/pgsql/bin/:$PATH
export PGDATA=/usr/local/pgsql/bin/data
sudo chown -R moiz /usr/local/pgsql/ 
Enter fullscreen mode Exit fullscreen mode

To initialize a database in a PostgreSQL database cluster, you can use the initdb command. This command creates the necessary directories and files for a new database cluster.

Here's the syntax:

initdb --username=<database superuser name> [other options] <database cluster location>
Enter fullscreen mode Exit fullscreen mode

For example:

initdb
Enter fullscreen mode Exit fullscreen mode

When you will execute the command the success message will be shown with the command to start the server.

Image description

Starting Server:-

pg_ctl start -l log
Enter fullscreen mode Exit fullscreen mode

Checking Server Status:-

pg_ctl status -l log
Enter fullscreen mode Exit fullscreen mode

Postgres :-

The command psql postgres is used to connect to a PostgreSQL database named "postgres". psql is a command-line interface to the PostgreSQL database system. When you run the psql postgres command, you will be logged in to the "postgres" database as the current operating system user.

psql postgres
Enter fullscreen mode Exit fullscreen mode

Apache-Age:-https://age.apache.org/
GitHub:-https://github.com/apache/age

Top comments (0)