FreeBSD Install PostgreSQL notes _postgresql

Source: Internet
Author: User
Tags postgresql create database postgres database

It has been a long time and has been reinitialized several times.

When installed, command: Pkg search PostgreSQL. A lot of bags, select the latest 9.4 installation server, will install the client together. There will be a lot of text prompts after the installation, which is useful. Installation will create a new user Pgsql, home directory for/usr/local/pgsql.

First step

To first switch to Pgsql user, Su root, su pgsql. Then create the Data folder in the Pgsql home directory. It doesn't seem to be allowed under the root user.
Initialization, initdb-d/usr/local/pgsql/data/, generates a lot of files. Initializing the database store automatically creates a Postgres database, setting up messy settings and data for Third-party Plug-ins. There will also be a template template1. It is not clear that the database will be created later with this template. Here to say is the problem of database coding, where the tragedy of the initialization of many times.
When the command is executed by default, the prompt text will tell you. The default database is encoded as "SQL_ASCII" and the default text search is set to 中文版. I am in the execution of the time to stare at the screen daze, and so on after execution ... The method of reinitialization, I also see from the hint, direct initdb will prompt you to empty the original folder or new. Direct RM-RF *.initdb–help
You can see the character encoding set with –encoding, initdb–encoding=utf8-d/usr/local/pgsql/data/

Start PostgreSQL, start script/usr/local/etc/rc.d/postgresql. It's also a hint to start adding to the/etc/rc.conf file.
Status not Running,start successful

Create DATABASE, Createdb–encoding=utf-8 BT, use client connection, Qsql BT,
Go in and show server_encoding; View server encoding, UTF8
\encoding View client code. Client or SQL_ASCII, you can use/encoding UTF8 to change the client's encoding.
You can also use \l to view it directly.

OK, basically there's no other problem.

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.