4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi上に練習用データベースを作成する

Posted at

忘れないうちにメモ。

Raspberry PiにPostgreSQLをインストール

事前にサンプルデータベースをダウンロードしておく。

sudo apt-get install postgresql
sudo passwd postgres 
su - postgres 
createuser -P pi
psql 
CREATE DATABASE dvdrental;
\q

ダウンロードしたサンプルデータベースのzipファイルがあるディレクトリで

unzip dvdrental.zip
pg_restore -U pi -d dvdrental ./dvdrental.tar
psql dvdrental
\dt

テーブル一覧が表示されればOK。

ログインテスト

Raspberry Pi側で

  • 設定 > Raspberry Piの設定 > インターフェイス > SSH > 有効

としておいた上でMacから

% ssh pi@192.168.11.11
pi@192.168.11.11's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Apr 20 21:07:41 2017 from 192.168.11.2
pi@raspberrypi:~ $ psql dvdrental
psql (9.4.10)
"help" でヘルプを表示します.

参考

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?