[root@weblogic opt]# groupadd postgresql
[root@weblogic opt]# useradd -g postgresql postgres
[root@weblogic opt]# passwd postgres
[root@weblogic opt]# chmod +x postgresql-9.2.19-1-linux-x64.run
[root@weblogic opt]# ll postgresql-9.2.19-1-linux-x64.run
-rwxr-xr-x 1 root root 39523652 Sep 6 01:12 postgresql-9.2.19-1-linux-x64.run
安装
[root@weblogic opt]# ./postgresql-9.2.19-1-linux-x64.run
next---next
配置环境变量
/etc/profile
export LD_LIBRARY_PATH=/opt/PostgreSQL/9.2/lib:$LD_LIBRARY_PATH
export PATH=/opt/PostgreSQL/9.2/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.2/data
source /etc/profile
su - postgres
cd /opt/PostgreSQL/9.2/bin
初始化数据库
initdb: invalid locale name ""
initdb: invalid locale name ""
initdb: invalid locale name ""
initdb: invalid locale name ""
initdb: invalid locale name ""
initdb: invalid locale name ""
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/PostgreSQL/9.2/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... locale: Cannot set LC_MESSAGES to default locale: No such file or directory
ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
or
./pg_ctl -D /opt/PostgreSQL/9.2/data -l logfile start
启动PG
[1] 18363
[postgres@weblogic bin]$ LOG: database system was shut down at 2019-09-06 01:59:02 PDT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postgres 18363 postgres 3u IPv4 439718 0t0 TCP *:postgres (LISTEN)
postgres 18363 postgres 4u IPv6 439719 0t0 TCP *:postgres (LISTEN)
[postgres@weblogic bin]$
登录PG
psql.bin (9.2.19)
Type "help" for help.
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
PG 版本查看:
version
----------------------------------------------------------------------------------------------------------------
PostgreSQL 9.2.19 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55), 64-bit
(1 row)