Install PostgreSQL under Linux and configure remote graphics desktop Connection

Source: Internet
Author: User
Tags psql unix domain socket file permissions

Recently there have been projects that have been used in PostgreSQL and have not been contacted before, so there are some problems with the installation and are now recorded.

1. Download postgresql9.4, I use the version is downloaded from the official website: http://download.csdn.net/detail/mu_wangyue/8679781 (if a friend want to follow my steps to do, it is recommended to download this connection). After download, copy the Postgresql-9.4.1-3-linux-x64.run to Linux (with tools such as XFTP), which I put in the/usr/local/soft directory.


2. modify file permissions and add Execute permissions. Command: chmod 755 postgresql-9.4.1-3-linux-x64.run


3. Add the installation directory before starting the installation, command: Mkdir-p/usr/local/sql/pgsql. Run Postgresql-9.4.1-3-linux-x64.run, directly enter the file name on the line


4. When you select the installation directory, enter the new directory you created in the previous step (you can also install it with the default directory), confirm the directory and return directly


5.postgresql has a built-in maximum privilege user Postgres, which sets the user's password


6. Set the port number


7. Setting the character set


8. Enter "Y" key to confirm the installation database


9. There may be warnings during the installation process, do not bother, continue to install



After the above steps, PostgreSQL installation is complete, the following start testing (some configurations will be explained in case of error, easy to understand the role of configuration and find errors)

1. Switch to the Postgres user and connect to the database using the Psql command in the installation directory. There will be an error when connecting:

Psql.bin:could not connect to server: No file or directory
is the server running locally and accepting
Connections on Unix domain socket "/tmp/.s.pgsql.5432"?


We can find it in the/tem directory, and indeed there is no ". s.pgsql.5432" file. There are two workarounds, one restart (this involves other issues, not the first), and the other with "-H".


2. After entering the command "/usr/local/sql/pgsql/bin/psql-h 127.0.0.1", the previous problem is resolved, and a new problem arises. Error:

Psql.bin:could not connect to server: Deny connection
is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?



This problem is caused because the database service is not started.


3. Start the database and use the PG_CTL command in the bin directory. However, the log and data directories must be set before starting. Create the "Pgdata" and "Pglog" directories under the "/usr/local/sql" directory.

Start command:/usr/local/sql/pgsql/bin/pg_ctl start-d/usr/local/sql/pgdata/-l/usr/local/sql/pglog/

This means that pgdata is just a generic directory, not a "database cluster" directory. To make the Pgdata directory that we create ourselves into a "database cluster" directory using the INITDB command under Bin

The reason for this failure is that you cannot find the directory that you want to "database cluster", either specify the directory in-D or configure the environment variable Pgdata. Here's how to configure environment variables.

Modify/etc/profile to configure environment variables. "Vi/etc/profile". At the end of the file, add the following configuration:

#set PostgreSQL Environment
Pg_home=/usr/local/sql/pgsql
Pgdata=/usr/local/sql/pgdata
Path= $PG _home/bin: $PATH
Export Pg_home PGDATA PATH

Restarting Linux makes the configuration effective. Execute command "Initdb" (because the environment variable is configured, do not need to hit the directory), error

Initdb:cannot be run as root
Please log on (using, e.g, "su") as the (unprivileged) user that would
Own the server process.

You cannot start with the root user, create a new user Postgres, and change the owner of the data directory to Postgres


Execute the command "Initdb" again, after successful execution, the contents of the Pgdata directory are:


Run command to start: pg_ctl-d/usr/local/sql/pgdata/-l/usr/local/sql/pglog/start


===========================================================================================================

In fact, the actual installation is not so complicated, the above is written just to show those errors, in order to know how to modify.

A simple installation method

1. Set up 3 directories before installation: Pgsql, data, log

2. Install the installation directory and the data directory (not specified as the default)



3. After the installation is complete, 3 directories are as follows (the system automatically establishes the Postgres user, and the data directory becomes the "database Cluster" directory):



4. Execute command: pg_ctl-d/usr/local/common/postgresql/data-l/usr/local/common/postgresql/log start service can be



Install PostgreSQL under Linux and configure remote graphics desktop Connection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.