23 พฤศจิกายน 2557

ติดตั้งฐานข้อมูล PostgreSQL บน FreeBSD

ติดตั้งฐานข้อมูล PostgreSQL บน FreeBSD
ติดตั้งจาก Ports บน FreeBSD:
# cd /usr/ports/databases/postgresql94-server/ && make install clean

ติดตั้งจาก package บน FreeBSD:
# pkg install databases/postgresql94-server
กำหนดค่าให้ PostgreSQL เริ่มทำงานตั้งแต่บูตเครื่อง FreeBSD ใช้คำสั่ง
# echo 'postgresql_enable="YES"' >> /etc/rc.conf
เริ่มต้นคลัสเตอร์ฐานข้อมูล PostgreSQL เป็นครั้งแรก ใช้คำสั่ง
# service postgresql initdb
จะได้ผลลัพธ์
# service postgresql initdb
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locales
COLLATE:  C
CTYPE:    en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: en_US.UTF-8
NUMERIC:  en_US.UTF-8
TIME:     en_US.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/pgsql ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /data/pgsql/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

   /usr/local/bin/postgres -D /data/pgsql
or
    /usr/local/bin/pg_ctl -D /data/pgsql -l logfile start
เริ่มการทำงาน ใช้คำสั่ง
# /usr/local/etc/rc.d/postgresql start
หรือ
# service postgresql start
สร้าง super user ของ postgresql โดยใช้คำสั่ง
# su pgsql
$ createuser -sdrP py
Enter password for new role: ******
Enter it again: ******

$ exit
แค่นี้เราก็ได้ฐานข้อมูล PostgreSQL บน FreeBSD แล้วครับ หากผู้อ่านต้องการใช้ PostgreSQL เวชั่นอื่น สามารถเปลี่ยนเลขเวชั่นแทนที่ postgresql94 เป็น postgresql87 เป็นต้น ได้เลยครับ

ไม่มีความคิดเห็น:

แสดงความคิดเห็น