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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义