Install POSTGRESQL on FREEBSD, freebsdpostgresql
It took a long time to reinitialize it many times.
During installation, run the command pkg search postgresql. Select the latest 9.4 to install the server, and the client will be installed together. There will be a lot of text prompts after installation, this is very useful. After installation, a user pgsql is created. The home directory is/usr/local/pgsql.
Step 1
Switch to the pgsql user first, su root, su pgsql. Then, create the data folder in the pgsql home directory. The root user is not allowed.
Initialization: initdb-D/usr/local/pgsql/data/generates many files. When the database storage area is initialized, an postgres database is automatically created to store messy settings and third-party plug-in data. There will also be a template template1. It is not clear here that this template will be used to create databases in the future. Here we are talking about the problem of database encoding. Here, the tragedy has been initialized many times.
By default, after the above command is executed, the prompt text will be told to you (I didn't see it at the time ..) The default database encoding is "SQL _ascii", and the default text search is set to english .. When I rely on the execution, I am stuck on the screen and wait until the execution is complete... The re-initialization method is also shown in the prompt. Direct initdb prompts you to clear the original folder or create a new one. Rm-rf *. initdb-help
-Encoding, initdb-encoding = UTF8-D/usr/local/pgsql/data/
Start postgresql and start the script/usr/local/etc/rc. d/postgresql. You are prompted to add it to the/etc/rc. conf file.
Status not running, start successful
Create Database, createdb-encoding = UTF-8 bt, use client connection, qsql bt,
Show server_encoding; check the server encoding and utf8
\ Encoding: view the client encoding. The client is also SQL _ASCII. You can use/encoding utf8 to change the client encoding.
You can also directly use \ l for viewing.
OK.