1. Install postgresql
Yum-y install postgresql-server postgresql-devel
Mkdir/work/pgdata
Useradd postgres-d/work/pgdata
Chown postgres. postgres-R/work/pgdata
Su-postgres
Vim ~ /. Add the following content to bash_profile:
Export PGHOME =/work/pgdata
Export PGDATA =/work/pgdata/data
II. Initialize and set the postgresql character set
1. Modify the system character set to: UTF-8
Vim/etc/sysconfig/i18n
LANG = "en_US.UTF-8"
2. Switch to the postgres account to initialize the database.
Initdb-E UTF8
3. Modify the postgresql configuration file
/Work/pgdata/data/postgresql. conf modification
Listen_addresses = '*'
Port = 5432
Max_connections = 1000
/Work/pgdata/data/pg_mirror.conf add a trusted network:
1
2
Host all 10.0.0.1/8 trust
Host all 192.168.0.0/24 trust
3. Start the database
/Etc/init. d/postgresql start
Chkconfig postgresql on
Ps aux | grep postgresql
Postgres 41659 0.0 0.0 216280 5840? S/usr/bin/postmaster-p 5432-D/work/pgdata/data
Postgres 41661 0.0 0.0 179292 1284? Ss postgres: logger process
Postgres 41663 0.0 0.0 216280 1764? Ss postgres: writer process
Postgres 41664 0.0 0.0 216280 1472? Ss postgres: wal writer process
Postgres 41665 0.0 0.0 216548 1808? Ss postgres: autovacuum launcher process
Postgres 41666 0.0 0.0 179420 1528? Ss postgres: stats collector process
Postgres 41686 0.0 0.0 218248 5428? Ss IPVS: opcode 192.168.0.80 (38453) idle
Postgres 41832 0.0 0.0 217636 4892? Ss postgres: postgres [local] idle
4. Create databases and corresponding accounts:
Su-postgres
The system prompt will change to "S = #", indicating that the database console has been started.
\ Password S; # set the password for postgres
Create user opcode with password 'opcodepasswd ';
Create database opcode OWNER opcode;
Grant all privileges on database opcode to opcode;
\ H: view the explanations of SQL commands, such as \ h select.
\? : View the psql command list. \ L: list all databases.
\ C [database_name]: connects to other databases.
\ D: list all tables of the current database.
\ D [table_name]: list the structure of a table.
\ Du: list all users.
\ E: open the text editor.
\ Conninfo: lists information about the current database and connection.
# Other knowledge
Createuser -- superuser postgres # Create and set the administrator account