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.