Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install PostgreSQL source code under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to install PostgreSQL source code under Linux, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

1. Install dependency packages first to avoid problems during installation

shell> yum install gcc gcc-c++ automake autoconf libtool makeshell> yum install readline-develshell> yum install zlib-devel

Create postgre users and user groups

shell> groupadd postgreshell> useradd -g postgre postgre shell> passwd postgre #Change Password shell> id postgreuid=500(postgre) gid=501(postgre) group =501(postgre)

3. Compile and install 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. Set database directory permissions and initialize database

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#initialize database 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. Setting environment variables

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. Start postgre service

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. Test connection database

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=# #Show current database 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)#exit command line mydb=# \q about "how to install PostgreSQL source code under Linux" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report