剑道第一仙

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

Suse安装PostgreSQL

【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 
复制代码

 

posted on   剑道第一仙  阅读(278)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示