安装Postgressql-13.4

安装Postgressql-13.4


1、创建用户和组

[root@ceshi3 ~]# groupadd postgres
[root@ceshi3 ~]# useradd -g postgres postgres

[root@ceshi3 postgres]# mkdir /postgres
[root@ceshi3 postgres]# tar -xvf postgresql-13.4
[root@ceshi3 postgres]# ls
postgresql-13.4 postgresql-13.4.tar.gz


[root@ceshi3 postgres]# mkdir /postgres/pgdata
[root@ceshi3 postgres13]# mkdir /usr/local/postgres13
[root@ceshi3 postgres13]#chown -R postgres:postgres postgres13/


3、编译

默认安装在/usr/local/pgsql目录下,可以通过--prefix指定安装目录

[root@ceshi3 postgresql-13.4]# cd /postgres/postgresql-13.4
[root@ceshi3 postgresql-13.4]# ./configure -prefix=/usr/local/postgres13 -without-readline
[root@ceshi3 postgresql-13.4]#make all
[root@ceshi3 postgresql-13.4]#make install


4、始化数据库
[postgres@ceshi3 pgdata]$ cd /usr/local/postgres13/bin/
[postgres@ceshi3 bin]$ ./initdb -D /postgres/pgdata/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /postgres/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
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.

Success. You can now start the database server using:

./pg_ctl -D /postgres/pgdata/ -l logfile start

[postgres@ceshi3 bin]$

5、启动数据库
gres@ceshi3 bin]$ ./pg_ctl -D /postgres/pgdata -l logfile start
waiting for server to start.... done
server started

6、查看

[root@ceshi3 ~]# su - postgres
[postgres@ceshi3 ~]$ cd /usr/local/postgres13/bin/

[postgres@ceshi3 bin]$ ./psql
psql (13.4)
Type "help" for help.

postgres=#

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| | | | | postgres=CTc/postgres
(3 rows)

postgres-# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

postgres=# create role test login;
CREATE ROLE

postgres=# alter user test with password 'test' ;
ALTER ROLE


postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
test |

 

posted @ 2022-11-04 11:12  戒痴  阅读(106)  评论(0编辑  收藏  举报