Installing PostgreSQL under Linux There are two installation methods for binary format installation and source installation, which is installed in binary format. Each version of Linux has a built-in PostgreSQL, so it can be installed directly from the command line. This article uses the Centos6.5.
Installing PostgreSQL
# Install the PostgreSQL server Yum Install postgresql-server# dependent package installs Y/N y# Third-party contribution package YumInstall postgresql-contrib# Dependent package installs Y/n y
After the installation is successful, the database state
[Email protected] hadoop]# service PostgreSQL Statuspostmaster is stopped
Attempt to start database, but error, need to initialize data directory first
[[Email protected] hadoop]# service PostgreSQL start " Service PostgreSQL Initdb " to initialize the cluster first.
[Email protected] hadoop]# service PostgreSQL initdb
Initializing database: [OK]
Start the database
To start PostgreSQL with the service command, it is important to note that by default, the Postgres user is created and installed under this user at the time of installation. The default database for PostgreSQL is also named by this user.
[ [email protected] hadoop]# service PostgreSQL startstarting PostgreSQL service: [OK ][[email protected] hadoop]#su-Postgres-bash-4.1$ psqlpsql (8.4. -) Type" Help" forHelp.postgres=# \l List of Databases Name| Owner | Encoding | Collation | Ctype |Access Privileges-----------+----------+----------+-------------+-------------+-----------------------Postgres| Postgres | UTF8 | en_US. utf-8| en_US. utf-8|Template0| Postgres | UTF8 | en_US. utf-8| en_US. utf-8| =c/Postgres:postgres=ctc/Postgres template1| Postgres | UTF8 | en_US. utf-8| en_US. utf-8| =c/Postgres:postgres=ctc/Postgres (3rows) Postgres=#
Postgresql Psql is equivalent to Oracle's Sqlplus, directly with the command Psql login equals the operating system authentication login, do not need to enter a user name and password.
Basic parameter Settings
Under CentOS, the default data directory under/var/lib/pgsql/data, the configured parameter file is in this directory.
-bash-4.1$ls-Ltotal thedrwx------5Postgres Postgres4096Nov - -: +basedrwx------2Postgres Postgres4096Nov - at:Wuyiglobaldrwx------2Postgres Postgres4096Nov - -: +Pg_clog-RW-------1Postgres Postgres3533Nov - A: topg_hba.conf-RW-------1Postgres Postgres1631Nov - -: +pg_ident.confdrwx------2Postgres Postgres4096Nov - xx:xxpg_logdrwx------4Postgres Postgres4096Nov - -: +pg_multixactdrwx------2Postgres Postgres4096Nov - xx:xxpg_stat_tmpdrwx------2Postgres Postgres4096Nov - -: +pg_subtransdrwx------2Postgres Postgres4096Nov - -: +pg_tblspcdrwx------2Postgres Postgres4096Nov - -: +Pg_twophase-RW-------1Postgres Postgres4Nov - -: +pg_versiondrwx------3Postgres Postgres4096Nov - -: +Pg_xlog-RW-------1Postgres Postgres16877Nov - +: Wupostgresql.conf-RW-------1Postgres Postgres $Nov - at:Wuyipostmaster.opts-RW-------1Postgres Postgres $Nov - at:WuyiPostmaster.pid
Configuring the Telnet database
1. Modify the postgresql.conf file to configure the appropriate parameters for the PostgreSQL database server
' * ' 5432 #default port, modify to restart database
2. Modify the pg_hba.conf file to configure access rights to the database
The last line is configured to allow all hosts on the network segment 192.168.191.0 to access the database using all legitimate database usernames.
24 is a subnet mask that represents a computer access that allows IP ranges in 192.168.191.0--192.168.191.255.
3. Test remote Login
First, modify the default database user login password
-bash-4.1$ psqlpsql (8.4. ' help ' for help.postgres =# \password
Follow the prompts to change your password.
And then log on from another LAN machine
192.168. 191.5 5432 --Success
Where –u specifies the user,-d specifies the database name,-h specifies the host,-p port number, and prompts for the password.
In addition, the visual client recommends Dbeaver, the following is the Dbeaver connection test.
Install Posgresql and set basic parameters under Linux