首页 > 数据库 >Suse安装PostgreSQL

Suse安装PostgreSQL

时间:2022-11-04 15:36:06浏览次数:43  
标签:zh PostgreSQL postgres data ----------------------------------------------------

【1】安装数据库

XXXX:/data/software # ls
postgresql-9.6.5-1-linux-x64.run
XXXX:/data/software # ./postgresql-9.6.5-1-linux-x64.run 
----------------------------------------------------------------------------
Welcome to the PostgreSQL Setup Wizard.

----------------------------------------------------------------------------
Please specify the directory where PostgreSQL will be installed.

Installation Directory [/opt/PostgreSQL/9.6]: /data/99postgresql9.6

----------------------------------------------------------------------------
Please select a directory under which to store your data.

Data Directory [/data/99postgresql9.6/data]: /data/99postgresql9.6/data

----------------------------------------------------------------------------
Please provide a password for the database superuser (postgres). A locked Unix 
user account (postgres) will be created if not present.

Password :
Retype password :
----------------------------------------------------------------------------
Please select the port number the server should listen on.

Port [5432]: 5432

----------------------------------------------------------------------------
Advanced Options

Select the locale to be used by the new database cluster.

Locale

[1] [Default locale]
[2] C
[3] C.utf8
...

[455] zh_CN.utf8
[456] zh_HK.utf8
[457] zh_SG

...
Please choose an option [1] : 455

----------------------------------------------------------------------------
Setup is now ready to begin installing PostgreSQL on your computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs PostgreSQL on your computer.

Installing
0% ______________ 50% ______________ 100%
#########################################

----------------------------------------------------------------------------
Setup has finished installing PostgreSQL on your computer.

XXXX:/data/software #

 

【2】初始化数据库

XXXX:/data/software # export PATH=$PATH:/data/99postgresql9.6/bin
XXXX:/data/software # psql -h 127.0.0.1 -U postgres -p 5432
Password for user postgres: 
psql.bin: FATAL:  password authentication failed for user "postgres"XXXX:/data/software # psql -h 127.0.0.1 -U postgres -p 5432
Password for user postgres: 
psql.bin (9.6.5)
Type "help" for help.

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

postgres=# CREATE DATABASE pgdb;
CREATE DATABASE
postgres=# CREATE USER pguser WITH PASSWORD 'xxxx';
CREATE ROLE
postgres=# ALTER USER  pguser CONNECTION LIMIT 20 login;
ALTER ROLE
postgres=# GRANT CONNECT ON DATABASE pgdb TO pguser;
GRANT
postgres=# GRANT USAGE ON SCHEMA public TO pguser;
GRANT
postgres=#  GRANT SELECT,update,INSERT,delete ON ALL TABLES IN SCHEMA public TO pguser;
GRANT
postgres=# ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pguser;
ALTER DEFAULT 

 

标签:zh,PostgreSQL,postgres,data,----------------------------------------------------
From: https://www.cnblogs.com/qsds/p/16857956.html

相关文章