PostgreSQLのインストールとデータの復元
PostgreSQLをインストールし、バックアップからデータを復元した。
インストールはyumコマンドから。
# yum install postgresql-server
...
...
そして、データベースの初期化。postgresユーザに変更してから、initdbコマンドを実行。以前のデータがEUC-JPだったので、デフォルト値をEUC-JPとして初期化した。
# su - postgres
$ echo $PGDATA
/var/lib/pgsql/data
$ initdb --no-locale --encoding=EUC_JP
...
$ echo $PGDATA
/var/lib/pgsql/data
$ initdb --no-locale --encoding=EUC_JP
...
とりあえず、サービス起動。
# /etc/init.d/postgresql start
...
...
そして、バックアップのデータを復元するのだが、pg_dumpコマンドによるバックアップのため、データベース作成やユーザ作成が必要。
# psql -U postgres template1
...
template1=# alter user postgres with password '****';
ALTER ROLE
template1=# create user db_user with password '****';
CREATE ROLE
template1=# alter user db_user with createdb;
ALTER ROLE
template1=# q
# createdb -U db_user mydb
...
# psql -U postgres -f backufile.sql mydb
...
...
template1=# alter user postgres with password '****';
ALTER ROLE
template1=# create user db_user with password '****';
CREATE ROLE
template1=# alter user db_user with createdb;
ALTER ROLE
template1=# q
# createdb -U db_user mydb
...
# psql -U postgres -f backufile.sql mydb
...
そして、設定。クライアントのデフォルト文字コードをEUC-JPに。アクセスはローカルホストからのみ許可で、ユーザ認証にMD5パスワードを利用。
# vi /var/lib/pgsql/data/postgresql.conf
...
client_encoding = EUC_JP
...
# vi /var/lib/pgsql/data/pg_hba.conf
...
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
...
client_encoding = EUC_JP
...
# vi /var/lib/pgsql/data/pg_hba.conf
...
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
サービスの再起動で、とりあえずの完了。
# /etc/init.d/postgresql restart
...
...
« リンケージ iPod マルチDocスタンド購入 | トップページ | phpPgAdminのインストール »
「パソコン・インターネット」カテゴリの記事
- モッピー(moppy)に登録したので広告(2013.10.12)
- VMware PlayerのBIOS画面表示(2012.12.10)
- ウイルスバスターのポップアップ広告を消す(2012.06.25)
「Linux」カテゴリの記事
- [Linux] ログイン画面のOS名表示など(2013.08.12)
- CentOSからWin7の共有フォルダへアクセス(2011.11.27)
- namazuのインストール手順(2011.09.02)
- mknmzで、エラー 'sh: line 1: no: command not found'(2011.08.30)
- PostgreSQL 8.1から7.3へデータ移行(2011.08.24)
この記事へのコメントは終了しました。
コメント