Linux下PostgreSQL如何源码安装
这篇文章将为大家详细讲解有关Linux下PostgreSQL如何源码安装,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1、首先安装依赖包,避免在安装过程中出现问题
shell>yuminstallgccgcc-c++automakeautoconflibtoolmakeshell>yuminstallreadline-develshell>yuminstallzlib-devel
2、创建postgre用户及用户组
shell>groupaddpostgreshell>useradd-gpostgrepostgreshell>passwdpostgre#修改密码shell>idpostgreuid=500(postgre)gid=501(postgre)组=501(postgre)
3、编译安装postgre
shell>tarzxvfpostgresql-9.3.6.tar.gzshell>cdpostgresql-9.3.6shell>./configure--prefix=/db/pgsqlshell>make&&makeinstallPostgreSQLinstallationcomplete.
4、设置数据库目录权限并初始化数据库
shell>mkdir-p/db/pgsql/datashell>chown-Rpostgre.postgre/db/pgsql/shell>cpcontrib/start-scripts/linux/etc/rc.d/init.d/postgresqlshell>su-postgre#初始化数据库shell>/db/pgsql/bin/initdb-D/db/pgsql/data/Thefilesbelongingtothisdatabasesystemwillbeownedbyuser"postgre".Thisusermustalsoowntheserverprocess.Thedatabaseclusterwillbeinitializedwithlocale"zh_CN.UTF-8".Thedefaultdatabaseencodinghasaccordinglybeensetto"UTF8".initdb:couldnotfindsuitabletextsearchconfigurationforlocale"zh_CN.UTF-8"Thedefaulttextsearchconfigurationwillbesetto"simple".Datapagechecksumsaredisabled.fixingpermissionsonexistingdirectory/db/pgsql/data...okcreatingsubdirectories...okselectingdefaultmax_connections...100selectingdefaultshared_buffers...128MBcreatingconfigurationfiles...okcreatingtemplate1databasein/db/pgsql/data/base/1...okinitializingpg_authid...okinitializingdependencies...okcreatingsystemviews...okloadingsystemobjects'descriptions...okcreatingcollations...okcreatingconversions...okcreatingdictionaries...oksettingprivilegesonbuilt-inobjects...okcreatinginformationschema...okloadingPL/pgSQLserver-sidelanguage...okvacuumingdatabasetemplate1...okcopyingtemplate1totemplate0...okcopyingtemplate1topostgres...oksyncingdatatodisk...okWARNING:enabling"trust"authenticationforlocalconnectionsYoucanchangethisbyeditingpg_hba.conforusingtheoption-A,or--auth-localand--auth-host,thenexttimeyouruninitdb.Success.Youcannowstartthedatabaseserverusing:/db/pgsql/bin/postgres-D/db/pgsql/data/or/db/pgsql/bin/pg_ctl-D/db/pgsql/data/-llogfilestart
5、设置环境变量
shell>vi.bash_profile==================================================================PATH=$PATH:$HOME/bin:/db/pgsql/binexportPGDATA=/db/pgsql/dataexportPGHOME=/db/pgsqlexportLANG=zh_CN.UTF-8exportPGPORT=5432exportPATH==================================================================shell>source.bash_profile
6、开启postgre服务
shell>pg_ctl-D/db/pgsql/data/-l/db/pgsql/log/logfilestartserverstartingshell>tail-f/db/pgsql/logfileLOG:databasesystemwasshutdownat2015-04-2017:59:36CSTLOG:databasesystemisreadytoacceptconnectionsLOG:autovacuumlauncherstarted
7、测试连接数据库
shell>createdbmydbshell>psql-h127.0.0.1-p5432-Upostgre-WmydbPasswordforuserpostgre:psql(9.3.6)Type"help"forhelp.mydb=##显示当前数据库mydb=#\lListofdatabasesName|Owner|Encoding|Collate|Ctype|Accessprivileges-----------+---------+----------+-------------+-------------+---------------------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/postgretemplate1|postgre|UTF8|zh_CN.UTF-8|zh_CN.UTF-8|=c/postgre+|||||postgre=CTc/postgre(4rows)#退出命令行mydb=#\q
关于“Linux下PostgreSQL如何源码安装”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。