postgresql - money168/cowsay GitHub Wiki
centos 7 install postgresql
postgresql port 5432
-
EPEL (postgresql 9.2)
yum install postgresql-server postgresql-contrib - first setup
postgresql-setup initdb - start service
systemctl start postgresql
#ๅฎ่ฃๅพๆๆฐๅขpostgresไฝฟ็จ่
๏ผไฝฟ็จpostgresๅๆไฝฟ็จ่
๏ผไฝฟ็จpostgresql
sudo -u postgres psql -c โSELECT version();โ
su โ postgres
psql็ปๅ
ฅpostgresqlๆไปคไป้ข
#็ขบ่ชversiom
SELECT version();
psql -c โSELECT version();โ
#ๆชขๆฅ็ปๅ
ฅ่ณ่จ
\conninfo;
#็ปๅบ
\q
=========
#Creating PostgreSQL Role and Database
#Only superusers and roles with CREATEROLE privilege can create new roles.
#In the following example, we will create a new role named test a database named testdb and grant privileges on the database.
#Create a new PostgreSQL Role
create role test;
#Create a new PostgreSQL Database
create database testdb;
#Grant privileges
#To grant permissions to the test user on the database we created in the previous step, run the following query:
grant all privileges on database testdb to test;
#Enable remote access to PostgreSQL server
#By default, the PostgreSQL server listens only on the local interface 127.0.0.1. To enable remote access to your PostgreSQL server open the configuration file postgresql.conf and add listen_addresses = โ*โ in the CONNECTIONS AND AUTHENTICATION section.
vim /var/lib/pgsql/data/postgresql.conf
#If you are running PostgreSQL version 10, the path to the file is /var/lib/pgsql/10/data/postgresql.conf.
/var/lib/pgsql/data/postgresql.conf
-
#โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
CONNECTIONS AND AUTHENTICATION
#โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- - Connection Settings -
listen_addresses = โ*โ # what IP address(es) to listen on;
-
#save the file and restart the PostgreSQL service with:
systemctl restart postgresql
#configure the server to accept remote connections by editing the pg_hba.conf file.
/var/lib/pgsql/data/pg_hba.conf
-
- TYPE DATABASE USER ADDRESS METHOD
- The user test will be able to access all databases from all locations using a md5 password
host all root 0.0.0.0/0 md5
- The user test will be able to access only the testdb from all locations using a md5 password
host testdb root 0.0.0.0/0 md5
- The user test will be able to access all databases from a trusted location (192.168.1.134) without a password
host all root 192.168.1.134 trust
-
=====