What is PostgreSQL?
PostgreSQL is a free relational database management system. It is designed to handle a wide range of workloads, from personal computers to data warehouses or mass web services. use more.
PostgreSQL installation guide
To prepare to install PostgreSQL, we need to prepare a vps with centos7 operating system
- Install the repository configuration package for Postgresql on centos
#sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm . - Check out Postgresql releases
#yum list postgresql* - Select and install the release version you want. In this tutorial we will install the postgresql version 11.
#sudo yum install postgresql11-server - Create a new PostgreSQL database cluster with
initdb
#sudo /usr/pgsql-11/bin/postgresql-11-setup initdb - Enable Postgresql
Start postgresql-11.
#sudo systemctl start postgresql-11
Enable automatic start of postgresql-11 every reboot.
#sudo systemctl enable postgresql-11
Check status postgresql-11
#sudo systemctl status postgresql-11. - Create user and database with postgresql
#sudo -u postgres psql
CREATE DATABASE bkns;
CREATE USER bkns123 WITH PASSWORD ‘1234567’;
GRANT ALL PRIVILEGES ON DATABASE bkns TO bkns123; - Log in the user and database just created
#psql –username “tên user” –password –host localhost “tên database”
If you get an error “psql: FATAL: Ident authentication failed for user” then please edit the following information.
#sudo -u postgres psql
# show hba_file;
Exit root mode and follow that path to edit the configuration file like so.
#vi /var/lib/pgsql/11/data/pg_hba.conf
Change the value of the following 2 lines
host all all 127.0.0.1/32 ident –>host all all 127.0.0.1/32 md5
host all all ::1/128 ident –>host all all ::1/128 md5
save it then restart the postgresql service
#sudo systemctl restart postgresql-11
then re-login the user and database just created
#psql –username “tên user” –password –host localhost “tên database”
Good luck
Thanh Tung
إرسال تعليق
إرسال تعليق