---
title: "How to install pgsql on Solaris 10"
author: "yangyi"
date: "2011-06-18T19:32:07Z"
tags: []
categories: ["数据库"]
slug: "how-to-install-pgsql-on-solaris-10"
draft: false
lastmod: "2011-06-20T20:14:33Z"
id: 1097524
url: "https://yangyi.iteye.com/blog/1097524"
---

1) Check out the OS version and architecture, such as:

bash-3.00# cat /etc/release
Solaris 10 5/08 s10s_u5wos_10 SPARC
bash-3.00# isainfo -b
64

2) Although it's not hard to build code from scratch, it's much easier to download the pre-build version. Say for this SunOS, the URL would be:
<http://wwwmaster.postgresql.org/download/mirrors-ftp/binary/v9.0.4/solaris/solaris10/sparc/postgresql-9.0.4-S10.sparc-64.tar.bz2>

3) Unzip the binaries at the aimed *INSTALL_DIR*: 
bunzip2 < postgresql-9.0.4-S10.sparc-64.tar.bz2 | tar xpf -

4) For Solaris, the buildin version will be 8.1, to override it, set PATH env to *INSTALL_DIR*/postgres/9.0-pgdg/64/bin before /usr/bin

5) $ Init the data folder: 
pg_ctl -D /usr/local/pgsql/data initdb

6) The default sa would be postgres with a *NULl* passwd

7) Start db:
pg_ctl start -l logfile

7) Creating a db using command:
createdb test

8) The default port used is 5432, now the server will be ready to accept connnections

9) Backup & Restore:
pg_dump -Ft mydb -f db.tar
pg_restore pg_restore -d newdb db.tar