鯖(FreeBSD)側
- PostgresSQLをFreeBSDにインストール
- PostgresSQLにデータベースとテーブル作成
- 結果として以下のようなものあるとする
> psql l List of databases Name | Owner | Encoding ++ chuchu | chuchu | EUC_JP mosimosi | mosimosi | UTF8 <このDataBaseを扱う mydb | chuchu | EUC_JP postgres | pgsql | EUC_JP template0 | pgsql | EUC_JP template1 | pgsql | EUC_JP (6 rows)
> psql mosimosi Welcome to psql 8.1.3, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit mosimosi=# \d List of relations Schema | Name | Type | Owner +++ public | mt_author | table | mosimosi public | mt_author_id | sequence | mosimosi public | mt_blog | table | mosimosi public | mt_blog_id | sequence | mosimosi public | mt_category | table | mosimosi public | mt_category_id | sequence | mosimosi public | mt_comment | table | mosimosi public | mt_comment_id | sequence | mosimosi public | mt_config | table | mosimosi public | mt_config_id | sequence | mosimosi public | mt_entry | table | mosimosi public | mt_entry_id | sequence | mosimosi ...
要するにこれはMobableTypeのDataBaseだったりしてます。mosimosi=# select * from mt_log_id; sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called ++++++++ mt_log_id | 27 | 1 | 9223372036854775807 | 1 | 1 | 32 | f | t (1 row) \q
とまあ、こんな風に。。。これはどうでもいいですが。
このDataBaseをWindowsからODBC経由でアクセスしようと企んでます。
- PostgresSQLのアクセス制限と認証を許可する。
>> su Password: # cd /usr/local/pgsql/data/ >> su pgsql
まずアクセス制限を解除する pg_hba.conf... # TYPE DATABASE USER CIDRADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust host all all 192.???.???.0/24 trust <とりあえずLANのネットワークアドレス毎許可???は伏字なので適当に... # IPv6 local connections: host all all ::1/128 trust
次に認証?の設定を変更 postgresql.conf... # # CONNECTIONS AND AUTHENTICATION # # Connection Settings listen_addresses = '*' # what IP address(es) to listen on; <コメントはずして*に変更 # commaseparated list of addresses; # defaults to 'localhost', '*' = all ...
編集したらふたたびsuにもどりpostmaster再起動# /usr/local/etc/rc.d/010.pgsql.sh restart postmaster stopped #
クライアント(Windows)側
- なにわともあれ、PostgreSQLのODBCドライバをインストール
コチラから落として、インストール
[http://www.postgresql.org/download/] PostgreSQL Downloads
+--[http://www.postgresql.org/ftp/odbc/] FileBrowser ODBC
+--[http://www.postgresql.org/ftp/odbc/versions/msi/] msi <--ここ
「更新(2007/07/29)」
- BCB6から使えるように設定する。
- DataBase Explorer起動
- オブジェクトからODBC Administrator起動
- システムDSNタブを開き、「追加」PostgreSQL Driver Setupでサーバやら設定
「更新(2007/07/29)」
Database, Server, UserName,Passwordをちゃんと設定
ODBC Administrator閉じる。
- DataBase ExplorerからBDE Administrator起動
- 「オブジェクト」から「新規作成」、「エリアスの新規作成」でPostgreSQLのドライバ選択
- データベースツリーに登録されるので、適度にエリアス名を設定、
- 「定義」タブで「ODBC DSN」で先ほど登録したものを選択、
- データベースツリーから設定したエリアスのツリーを開こうとするとログインダイアログが出るので設定してログインできればOK
- DataBase Explorer起動
- SQL問い合わせできたしOKじゃね?