Linux下PostgreSQL如何源码安装
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,这篇文章将为大家详细讲解有关Linux下PostgreSQL如何源码安装,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。1、首先安装依赖包,避免在安装过程中出现问题s
千家信息网最后更新 2026年11月01日Linux下PostgreSQL如何源码安装
这篇文章将为大家详细讲解有关Linux下PostgreSQL如何源码安装,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1、首先安装依赖包,避免在安装过程中出现问题
shell> yum install gcc gcc-c++ automake autoconf libtool makeshell> yum install readline-develshell> yum install zlib-devel
2、创建postgre用户及用户组
shell> groupadd postgreshell> useradd -g postgre postgre shell> passwd postgre #修改密码shell> id postgreuid=500(postgre) gid=501(postgre) 组=501(postgre)
3、编译安装postgre
shell> tar zxvf postgresql-9.3.6.tar.gzshell> cd postgresql-9.3.6shell> ./configure --prefix=/db/pgsqlshell> make && make install PostgreSQL installation complete.
4、设置数据库目录权限并初始化数据库
shell> mkdir -p /db/pgsql/datashell> chown -R postgre.postgre /db/pgsql/shell> cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresqlshell> su - postgre# 初始化数据库shell> /db/pgsql/bin/initdb -D /db/pgsql/data/The files belonging to this database system will be owned by user "postgre".This user must also own the server process.The database cluster will be initialized with locale "zh_CN.UTF-8".The default database encoding has accordingly been set to "UTF8".initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"The default text search configuration will be set to "simple".Data page checksums are disabled.fixing permissions on existing directory /db/pgsql/data ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBcreating configuration files ... okcreating template1 database in /db/pgsql/data/base/1 ... okinitializing pg_authid ... okinitializing dependencies ... okcreating system views ... okloading system objects' descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionaries ... oksetting privileges on built-in objects ... okcreating information schema ... okloading PL/pgSQL server-side language ... okvacuuming database template1 ... okcopying template1 to template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: enabling "trust" authentication for local connectionsYou 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: /db/pgsql/bin/postgres -D /db/pgsql/data/or /db/pgsql/bin/pg_ctl -D /db/pgsql/data/ -l logfile start
5、设置环境变量
shell> vi .bash_profile==================================================================PATH=$PATH:$HOME/bin:/db/pgsql/binexport PGDATA=/db/pgsql/dataexport PGHOME=/db/pgsqlexport LANG=zh_CN.UTF-8export PGPORT=5432export PATH==================================================================shell> source .bash_profile
6、开启postgre服务
shell> pg_ctl -D /db/pgsql/data/ -l /db/pgsql/log/logfile start server startingshell> tail -f /db/pgsql/logfileLOG: database system was shut down at 2015-04-20 17:59:36 CSTLOG: database system is ready to accept connectionsLOG: autovacuum launcher started
7、测试连接数据库
shell> createdb mydbshell> psql -h 127.0.0.1 -p 5432 -U postgre -W mydbPassword for user postgre: psql (9.3.6)Type "help" for help.mydb=# # 显示当前数据库mydb=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+---------+----------+-------------+-------------+--------------------- mydb | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | postgres | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | template0 | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre + | | | | | postgre=CTc/postgre template1 | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre + | | | | | postgre=CTc/postgre(4 rows)# 退出命令行mydb=# \q
关于"Linux下PostgreSQL如何源码安装"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
数据
数据库
篇文章
源码
更多
用户
不错
实用
内容
变量
命令
密码
文章
权限
环境
用户组
目录
知识
过程
问题
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中国互联网科技工作委员会毛军
金融科技还是互联网
致骋互联网科技
有木互联网科技
米客互联网科技
狮子座互联网科技培训
天速互联网络科技有限公司
新华互联网科技2019
互联网科技与大数据专业
允成互联网科技有限公司融资
东莞新华互联网科技学校
互联网在线教育科技创业
朱啸虎曾投资哪些互联网科技企业
互联网第三次科技革命特征
梅州GM互联网络科技有限公司
江苏互联网智能科技软件
富国互联网金融科技混合基金
广州燕处互联网科技有限公司
宁波跨境商互联网科技有限公司
深圳互联网科技园地址
互联网科技公司经营范围
苏州互联网科技贷款公司
电子科技大学互联网
国外互联网科技网站
贵州叶脉互联网科技有限公司所属行业
互联网新科技动漫ppt素材
深圳艾果互联网通讯科技
合肥互联网科技公司公章图片
易企秀互联网科技是做什么的
互联网的科技体现在哪里