PostgreSQL is one of the most advanced open-source relational databases. Due to its excellent support for JSON and JSONB data types, PostgreSQL has gained a lot of user support. For problems that NoSQL non relational databases (such as MongoDB) are good at solving, PostgreSQL can also provide good solutions.
Taking a CentOS 7 cloud server as an example, this article introduces the installation method of PostgreSQL 13 version.
$ sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
$ sudo yum install -y postgresql13-server
Initialize the database.
$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Set to start automatically with the system.
$ sudo systemctl enable --now postgresql-13
PostgreSQL has created a default user postgres for executing the psql command line. Execute the following command to switch to the user.
$ sudo -iu postgres psql
Create a test database and connect to it.
$ CREATE DATABASE test;
$ \c test
Create a data table named message in the database.
$ CREATE TABLE messages (handle VARCHAR(32), message VARCHAR(280));
$ INSERT INTO messages VALUES ('User', 'This is a test message.');
$ INSERT INTO messages VALUES ('User', 'This is another test message.');
View the content of the data table. The two records added in the previous step should be displayed.
$ SELECT * FROM messages;
For more information, please refer to the official documentation of PostgreSQL.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58