8
8

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.

リモートサーバ上のDBをlocalhost(MAMP)に移行する

Last updated at Posted at 2014-06-04

1.リモートサーバでdbをdump!!

リモートサーバにアクセスしたら、ホームディレクトリで

[ユーザ名@ホスト名]mysqldump -u ユーザ名 -pパスワード DB名 > dump.sql

これで、ホームディレクトリにdump.sqlが生成されます。

2.リモートからローカルに移動

scpコマンドを使います。

参考:
http://docs.oracle.com/cd/E37932_01/html/E36612/remotehowtoaccess-55154.html

scp ユーザ名@ホスト名:ファイル名 移動先のディレクトリ

(例)
scp root@host.jp:dump.sql /Application/ディレクトリ名/

詳しいscpコマンドについては[コチラの記事]をご覧ください。
[コチラの記事]:http://qiita.com/maximum80/items/26034cf51f1ed5ce5988

3.PhpMyAdminでDBをインポート

これは楽勝。

①phpmyadminでDBを作成

リモートサーバと同じ名前が良いです。

②インポート

importをクリックしてDBをインポート。

Screen Shot 2014-06-04 at 8.40.15 PM.png

以下の画面で先ほどのdump.sqlを選択してGO!!
Screen Shot 2014-06-04 at 8.43.23 PM.png

GOしたあとに、

Import has been successfully finished, 264 queries executed. (dump.sql)

が表示されたらおっけー!!

4.db.phpの設定

これはFuel.phpの場合で書きますが、
要するにDBにアクセスするためのユーザ設定がローカル設定になっているかを確認しましょう。

$ vim fuel/app/config/development/db.php

でdbの設定ファイルを開いて

db.php
return array(
        'default' => array(
                'connection'  => array(
                        'dsn'        => 'mysql:host=localhost;dbname=dmtc',
                        'username'   => 'root',
                        'password'   => 'root',
                ),
        ),
);

のユーザ名、パスワードが正しいか確認してね!
これで正常に動いてくれるはず!

8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?