FreeBSD Install PostgreSQL Novice Tutorial
Author: heiyeluren QQ group: 5415735 (FreeBSD installation and maintenance group) Date: 2004/9/17 - special thanks QQ group Friends Anan, the paper was produced under the guidance of his patience -
PostgreSQL is an open source database management system, PostgreSQL is a very complex object-relational database management system (ORDBMS), is also the most powerful, most complete and most complex free software database system. Many of its characteristics are the predecessor of many commercial databases today, some characteristics and even commercial databases do not have. Relative to Mysql, PostgreSQL is a very thorough open source program developed by many hackers, currently it is standard for REDHAT and other Linux operating systems. :-)
Today we will say that postgreSQL installed on the FreeBSD platform, but there is nothing complicated, just a summary of the installation process in these two days, I hope to be able to install a prompt. (The FreeBSD system we use is 5.2.1, other installation platforms should be similar, we have all the following postgreSQL all hand, you can also use ports)
First go to the official FTP server of PostgreSQL, download the installer back, the version I use is 7.4.5, the size is 11.9MB. (After all, it is the source code, not very big, huh, huh) download address: ftp://ftp.postgreSQL.org/pub/v7.4.5/postgreSQL-7.4.5.tar.gz After downloading, we put it in / usr / Under the src directory, first decompress the program:
# TAR ZXVF PostgreSQL-7.4.5.tar.gz
After decompression, generate the postgreSQL-7.4.5 directory, enter the directory:
# cd postgreSQL-7.4.5
Configuration program and installation directory:
# ./configure --prefix = / usr / local / pgsql
Our installer needs to use Gmake instead of using Make, so we have to check our system if there is a gmake:
# Gamkegmake: Command Not Found.
It seems that our system does not have gmake, so we must install Gmake first, we use FreeBSD's expertise Ports to install,: (if your system has gmake, continue to install PostgreSQL)
# Whereis gmake # first, find our gmake's ports where gmake: / usr / ports / wevel / gmake # Oh, here, huh, huh # cd / usr / ports / wehake # make install # Oh, we start Ports. . .
Generally, wait for ten minutes, I have waited for 12 minutes, according to the speed of the network.
Install Gamke, we can find it in / usr / local / bin:
# ls -l / usr / local / bin / gamke-r-xr-xr-x 1 root wheel 144196 Sep 17 11:59 / usr / local / bin / gmake
Then we can use Gmake to continue to install our PostgreSQL, of course, you can first install Gmake and then install the PostgreSQL, we continue:
# CD /USR/SRC/PostgreSQL-7.4.5 # Enter the POSTGRESQL installation directory # / usr / local / bin / gmake # Execute Gmake to compile # / usr / local / bin / gmake install # to install, the program will be installed / usr / local / pgsql directory If you have an error above, follow the installation step to check if you operate correctly. Because running PostgreSQL In order to securely consider can't use root users, we have to build a user to specifically run PostgreSQL:
# PW user add postgres # Add a user # mkdir / usr / local / pgsql / data # MKDIR / USR / local / PGSQL / DATA # Newly built folders for storing the database
In order to allow Postgres to fully control the data directory, we set the permissions:
# chown postgres / usr / local / pgsql / data
After setting permissions, we switch to Postgres users:
# su postgres
Rear initial database:
$ / usr / local / pgsql / bin / initdb -d / usr / local / pgsql / data
Oh, if there is nothing wrong with it, our postgreSQL is basically installed, we will start PostgreSQL:
$ / usr / local / pgsql / bin / postmaster -d / usr / local / pgsql / data 启 启 p p p 启 p
$ LOG: could not create socket for statistics collector: Protocol not supportedLOG: database system was shut down at 2004-09-17 14:20:52 CSTLOG: checkpoint record is at 0 / 9B6E1CLOG: redo record is at 0 / 9B6E1C; undo Record is at 0/0; shutdown truelog: Next Transaction ID: 541; Next Oid: 17143log: Database System Is Ready
At this time, the program stopped here, because the program has been launched, can not end the current program, otherwise the database will end running, then we will open another terminal to POSTGRES users
View the process after logging in:
$ TOP
PID Username Pri Nice Size Res State Time WCPU CPU Command 891 Postgres 96 0 13508K 2708K SELECT 0:00 0.00% 0.00% Postgres
If you see a similar process above, then our PostgreSQL starts success and can use it.
Finally create a database:
$ / usr / local / pgsql / bin / createdb test # created a database TestCreate Database
After creating a database success, you can connect the past through the PostgreSQL client:
$ / usr / local / pgsql / bin / psql test
Welcome to PSQL 7.4.5, The PostgreSQL Interactive Terminal.
TYPE: / COPYRIGHT for Distribution Terms / H for help with sql commands /? For help on infant slash commands / g or terminate with semicolon to execute query / q to quittest = #
Finally, Test = # is a terminal prompt, then you can manage PostgreSQL and execute SQL statements here, please refer to the PostgreSQL manual.
Reference: PostgreSQL Chinese Manual http://www.pgsqldb.org/pgsqldoc-7.4/index.htmlpostgreSQL Chinese Web site http://www.pgsqldb.org
Writetime: 2004-9-17