• 2020-05-06 11:54:47
  • OfStack

It's been a long time, it's been reinitialized a lot.

When installing, command: pkg search postgresql. A lot of packages, choose the latest 9.4 installation server, client will be installed together. After the installation there will be a lot of text hints, this is very useful. Installed pgsql will create a new user, the home directory of/usr local/pgsql.

The first step

To switch to pgsql, su root, su pgsql. Then create the data folder in the pgsql home directory. root users appear to be under the disallow
Initialization, initdb D/usr/local/pgsql data /, will generate a lot of files. Initializing the database storage area will automatically create an postgres database, with messy Settings and third-party plug-in data. There will also be a template template1. It's not clear here, but we'll use this template to create the database later. This is about database coding, where the tragedy is initialized many times.
When the above command is executed by default, the prompt text will tell you. The default database code is "sql_ascii" and the default text search is set to english. I rely on the implementation of the time staring at the screen in a daze, just wait for the execution... The reinitialization method, which I also saw from the prompt, directly initdb will prompt you to empty the original folder or create a new one. Direct rm-rf *.initdb, help
Can see the character encoding setting with � encoding, initdb � encoding = UTF8 - D/usr/local/pgsql/data/

Start postgresql, startup scripts/usr/local/etc/rc d/postgresql. Start by adding to the /etc/ rc.conf file, which is also prompted.
status not running,start

Create the database, createdb, encoding= UTF-8 bt, use the client connection, qsql bt,
show server_encoding; View server code, utf8
\encoding view client code. The client is still SQL_ASCII, you can use /encoding utf8 to change the client encoding.
You can also view it directly using \l.

ok has almost no other problems.

Related articles: