Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressをローカルサーバーからライブサイトに移動する方法(2つの方法)

WordPressユーザーの多くは、コンピューター上のローカルサーバーを使用してサイトで作業することを好みます。これにより、オンラインで変更を公開する前に、個人的にサイトで作業することができます。

最終的には、ライブサーバーに移行し、オンライン訪問者がアクセスできるようにする必要があります。この移行は、本番サイトでサイトが正しく機能するようにするために非常に重要です。

私たちは多くのローカルサイトに携わってきたので、コンテンツをライブサイトに移行する最も簡単な方法を学ぶ必要がありました。

この投稿では、WordPressをローカルサーバーからライブサイトに移行する方法をステップバイステップで説明します。

How to move WordPress from local server to live site (2 methods)

なぜWordPressをローカルサーバーからライブサイトに移行するのか?

WordPressブログをローカルサーバーに構築することは、訪問者に影響を与えることなくサイトの変更をテストする安全な方法です。

サイトの完成度が高まったら、次のステップはローカルサーバーからライブサイトに移行することです。

ローカルサーバーからライブサイトにサイトを移動する2つの方法を紹介しよう。

最初の方法はWordPressの移行プラグインを使用するもので、初心者におすすめです。

2つ目の方法では、WordPressをローカルサーバーからライブサイトに手動で移動する方法を紹介します。

自分に合った方法を選べばいい:

WordPressサイトを移行する前に

WordPressをローカルサーバーからライブサーバーに移行するには、いくつかの準備が必要です。

まず、コンピューター上のローカルサーバー(localhostとも呼ばれる)でWordPressサイトが稼動しており、そのサーバーにフルアクセスできると仮定する。

次に、ドメイン名と ホスティングサービスが必要です。

私たちは、貧弱なプロバイダーや無料のホスティングサービスから始めて後悔した初心者から数え切れないほどの話を聞いてきました。私たちの経験では、適切なホスティングサービスを選択することは、任意のサイトの成功に不可欠です。

あなたの決定を容易にするために、私たちはBluehostを使用することをお勧めします。Bluehostは公式推奨のWordPressホスティングサービス会社で、WPBeginnerユーザーに限定割引+ドメインとSSLを無料で提供しています。

基本的に、月額1.99ドルから始めることができる。

あなたは偉大なBluehostの代替をしたい場合は、Hostingerを見ることができます。彼らはまた、無料のドメイン名とWPBeginnerユーザーに排他的な割引を提供しています。

もう少し支払う余裕があるなら、SiteGroundをチェックしよう。WPBeginner読者向けの特別価格もあります。

サイトの立ち上げにお困りの方は、ステップ・バイ・ステップのガイドに従ってください。

最後に、FTPプログラムと、ローカルサーバーのサイトをライブサイトにアップロードするためのFTPの使い方を知っている必要があります。

準備はいいですか?WordPressサイトの移行を始めましょう。

動画チュートリアル

Subscribe to WPBeginner

もし、文章での説明がお望みなら、このまま読み進めてほしい。

方法1:移行プラグインを使ってWordPressをローカルサーバーからライブサイトに転送する(推奨)

この方法は簡単で、初心者におすすめです。WordPress移行プラグインを使用して、WordPressをローカルホストからライブサイトに移行します。

ステップ1:Duplicatorプラグインのインストールとセットアップ

まず、ローカルサイトにDuplicatorプラグインをインストールして有効化する必要があります。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

プロのヒント Duplicatorのプロバージョンもあり、安全なバックアップ、クラウドストレージ、簡単なサイトの復元などが可能です。

有効化した後、Duplicator ” Packagesページで’新規作成’ボタンをクリックしてください。

Create new package for migration

バックアップに名前を付ける画面になります。

そして、「次へ」ボタンをクリックする。

Name backup package

Duplicatorはいくつかのテストを実行し、すべてが正常かどうかを確認します。

すべての項目が「Good」となっていれば、「Build」ボタンをクリックする。

Build package

サイトのサイズによっては、この処理に数分かかる場合があります。完了するまで、このタブを開いたままにしておく必要があります。

完了すると、「インストーラ」と「アーカイブ」パッケージのダウンロードオプションが表示されます。両方のファイルをコンピューターにダウンロードするには、「ワンクリックダウンロード」リンクをクリックする必要があります。

Download package files

アーカイブ」ファイルはWordPressサイトの完全なコピーです。WordPressのコアファイル、画像、アップロード、テーマ、プラグイン、WordPressデータベースのバックアップがすべて含まれています。

インストーラ」ファイルは、サイトを含むアーカイブファイルを解凍することで、移行プロセス全体を自動化するスクリプトです。

ステップ2: WordPressサイトのデータベースを作成する

インストーラを実行したり、WordPressウェブサイトをローカルホストからホスティングサービスサーバーにアップロードしたりする前に、新しいライブウェブサイト用のMySQLデータベースを作成する必要があります。

すでにMySQLデータベースを作成している場合は、このステップは省略できる。

データベースを作成するには、ホスティングサービスのcPanelダッシュボードにアクセスする必要があります。次に、「データベース」セクションを探し、「MySQLデータベースウィザード」アイコンをクリックします。

MySQL Database Wizard

次の画面では、新しいデータベースを作成する欄がある。

データベースの名前を入力し、「データベースを作成」ボタンをクリックします。

Name new database

cPanelはあなたのために新しいデータベースを作成します。

その後、新規ユーザーのユーザー名とパスワードを入力し、「Create User」ボタンをクリックします。

Create new database user

次に、作成したユーザーをデータベースに追加する必要があります。

まず、「すべての権限」のチェックボックスをクリックします。

Check all privileges

その後、下にスクロールして「変更を加える」ボタンをクリックし、変更を保存します。

これでWordPressサイトでデータベースを使用する準備が整いました。データベース名、ユーザー名、パスワードは本当に〜してもよいですか?この情報は次のステップで必要になります。

ステップ3:ローカルサーバーからライブWordPressサイトへのファイルのアップロード

ここで、アーカイブとインストーラファイルをローカルサイトからホスティングサービスアカウントにアップロードする必要があります。

まず、FTPクライアントを使用してライブサイトに接続します。接続したら、サイトのルートディレクトリが完全に空であることを確認してください。

通常、ルート・ディレクトリは/home/public_html/フォルダーです。

WordPressホスティングサービス会社によっては、サインアップすると自動的にWordPressがインストールされます。もしそこにWordPressのファイルがあるなら、削除する必要がある。

その後、Duplicatorから空のルートディレクトリにarchive.zipとinstaller.phpファイルをアップロードします。

Upload archive and installer files

ステップ4:移行スクリプトの実行

移行ファイルのアップロードが完了したら、ブラウザーで以下のURLにアクセスする必要があります:

http://example.com/installer.php

example.com」を自分のドメイン名に置き換えることをお忘れなく。

Duplicator 移行ウィザードが起動します。

インストーラはいくつかのテストを実行し、スクリプトを初期化します。

Duplicator migration wizard step 1

Setup セクションでは、MySQL ホスティングサービス、データベース名、ユーザ名、パスワードを入力するよう求められます。

ホスティングサービスはローカルホストになるでしょう。その後、先のステップで作成したデータベースの詳細を入力します。

その後、’Validate’ボタンをクリックし、入力した内容が正しいことを確認します。

Validate settings

その後、「Next(次へ)」ボタンをクリックして進みます。

Duplicatorはアーカイブから新しいデータベースにWordPressデータベースのバックアップをインポートします。

また、ローカルサイトと新しいライブサイトを指すURLも更新されます。

管理者ログイン」ボタンをクリックして、ライブサイトのWordPress管理エリアに入ることができます。

Admin login

ライブサイトにログインすると、Duplicatorは自動的にインストールファイルをクリーンアップします。

これですべてです。ローカルサーバーからライブサイトへのWordPressの移動は成功です。

方法2:WordPressをローカルサーバーからライブサイトに手動で転送する。

この方法では、WordPressをローカルサーバーからライブサイトに手動で移動する方法を紹介します。最初の方法がうまくいかなかった場合や、手動で行いたい場合に役立ちます。

ステップ1:ローカルのWordPressデータベースをエクスポートする

最初に行う必要があるのは、ローカルのWordPressデータベースをエクスポートすることです。そのためにphpMyAdminを使用します。

phpMyAdminに慣れていない方は、phpMyAdminを使ったWordPressデータベース管理のガイドをご覧ください。

http://localhost/phpmyadmin/、WordPressデータベースをクリックします。次に、上のメニューバーから「エクスポート」ボタンをクリックします。

Export from localhost

Export method:’オプションで、’Quick’または’Custom’を選択できます。カスタマイザーでは、データベースをエクスポートするためのオプションが増えます。

しかし、「クイック」を選択し、「Go」ボタンをクリックしてデータベースをダウンロードすることをお勧めします。

Export WordPress database using phpMyAdmin

ステップ2:WordPressファイルをライブサイトにアップロードする

次に、すべてのウェブサイトファイルをライブサイトに移動する必要があります。

まず、FTPクライアントを開き、ホスティングサービスアカウントに接続します。

ライブサイトに接続したら、正しいディレクトリにファイルをアップロードしていることを確認してください。例えば、サイトを’yoursite.com’にホスティングサービスしたい場合、public_htmlディレクトリにすべてのファイルをアップロードします。

ローカルのWordPressファイルを選択し、ライブサーバーにアップロードします。

Upload WordPress files FTP

ステップ3: ライブサイトにMySQLデータベースを作成する

FTPクライアントがWordPressファイルをアップロードしている間に、データベースのライブサーバーへのインポートを開始できます。

ほとんどのWordPressホスティングサービスプロバイダは、あなたのホスティングアカウントを管理するためにcPanelを提供していますので、我々はcPanelを使用してデータベースを作成する方法を紹介します。

まず、cPanelダッシュボードにログインし、「データベース」セクションにある「MySQLデータベースウィザード」アイコンをクリックします。

Select MySQL database wizard

次の画面では、新しいデータベースを作成することができます。

データベースの名前を入力し、「データベースを作成」をクリックします。

Name and create new database

cPanelは自動的に新しいデータベースを作成します。

次に、新規ユーザーのユーザー名とパスワードを入力し、「ユーザーを作成」をクリックします。

Create new database user

その後、作成したユーザーをデータベースに追加する必要がある。

まず、’All Privileges’ チェックボックスをチェックする。

Check all privileges checkbox

その後、下にスクロールして「変更を加える」をクリックし、変更を保存します。

WordPressサイトの新規データベースの作成が完了しました。

ステップ4:WordPressデータベースをライブサイトにインポートする

次のステップでは、WordPressデータベースをインポートします。

cPanelのダッシュボードに行き、「データベース」セクションまでスクロールダウンし、「phpMyAdmin」をクリックします。

Click on phpMyAdmin

phpMyAdminに移動し、先ほど作成したデータベースをクリックします。phpMyAdminには、テーブルのない新しいデータベースが表示されます。

次に、上部メニューの「インポート」タブをクリックします。インポートページで「ファイルを選択」ボタンをクリックし、最初のステップで保存したローカルサイトのデータベースファイルを選択します。

Import database via phpMyAdmin

その後、ページ下部の「Go」ボタンをクリックします。データベースが自動的にphpMyadminにインポートされます。

ステップ5:サイトURLの変更

次に、データベースのサイトURLを変更して、ライブWordPressサイトに接続できるようにする必要がある。

phpMyAdminで、先ほどインポートしたデータベースのwp_optionsテーブルを探します。

データベースのプレフィックスを変更した場合、wp_optionsの代わりに{new_prefix}_optionsになるかもしれません。

次に、wp_optionsの隣にある「Browse」ボタンをクリックします。または、サイドバーのリンクをクリックして、wp_optionsテーブル内のフィールドのリストがあるページを開きます。

Browse the wp options table

次にoptions_nameカラムでsiteurlオプションを探す必要があります。

次に「編集」アイコンをクリックする。

Edit siteurl in phpMyAdmin

フィールドを編集するウィンドウが表示されます。

入力ボックスoption_valueには、ローカルインストールのURLが表示されます。http://localhost/test のようなものです。

このフィールドに新規サイトのURLを挿入する必要があります。例:https://www.wpbeginner.com.

その後、「Go」ボタンをクリックしてフィールドを保存することができます。

edit the siteurl field

次に、上記と同じ手順でホーム・オプション名を設定します。wp_optionsメニューは数ページにわたることがあります。通常、ホームオプションは2ページ目に設定されます。

次に、ホームURLを更新し、ライブサイトのURLと同じにする。

ステップ6: ライブサイトのセットアップ

データベースのインポートとコンテンツのアップロードが完了したら、次はWordPressの設定です。

このとき、サイトには「Error establishing a database connection(データベース接続の確立エラー)」というエラーが表示されているはずです。

これを修正するには、FTPクライアントを使用してサイトに接続し、wp-config.phpファイルを開きます。

以下のコード行を探すことになる:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

先に作成したデータベース名、ユーザー名、パスワードをプロバイダーとして入力する必要があります。

次に、wp-config.phpファイルを保存し、WordPressホスティングサービスサーバーにアップロードします。

さて、あなたのサイトにアクセスすると、それはライブであるべきだ。

その後、WordPress管理画面にログインし、設定 ” 一般に移動する必要があります。その後、何も変更せずに一番下までスクロールし、「変更を保存」ボタンをクリックします。

Save general settings

これにより、サイトのURLが必要な場所に修正されるようになります。

それができたら、設定 ” パーマリンクに行き、スクロールダウンして「変更を保存」をクリックし、すべての投稿リンクが問題なく機能していることを確認してください。

Save permalinks settings

WordPressサイトをあるドメインから別のドメインへ、またはローカルサーバーからライブサイトへ移動する際には、必ずリンク切れや画像の欠落に直面します。

URLを更新する2つの方法をご紹介します。あなたに最適な方法を選んでください。

1.Search & Replace Everythingプラグインを使ってURLを更新する(推奨)

これを解決する最も安全な方法は、Search & Replace Everythingを使用することです。これは強力なWordPressプラグインで、複雑なデータベースクエリーを書くことなく、簡単にサイトの一括更新作業を行うことができます。

まず、Search & Replace Everythingプラグインをインストールして有効化する必要があります。

有効化した後、Tools ” WP Search & Replaceページにアクセスしてください。

Search and replace URLs from local to live site migration

ここから、’Search for’フィールドにローカルサイトのURLを、’Replace with’フィールドにライブサイトのURLを入力する必要があります。

少しスクロールして、テーブルの下の「すべて選択」をクリックします。これにより、プラグインがデータベース内のあらゆる場所で古いURLを探すようになります。

Select tables

ここで「検索と置換のプレビュー」ボタンをクリックして続行する。

プラグインは、古いURLのすべてのインスタンスをデータベースから検索し、結果をプレビューします。

Preview changes

問題がなければ、「すべて置換」をクリックして変更を保存する。

変更についての警告が表示されます。続行するには「はい」をクリックしてください。

プラグインはデータベースを更新し、ローカルのURLを現在のサイトのURLに置き換えます。

2.手動でURLを更新する(上級者向け)

URLを更新するもう一つの方法は、以下のSQLクエリーを使うことである:

UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');

phpMyAdminにアクセスしてデータベースをクリックし、上部メニューから「SQL」をクリックして上記のクエリーを追加するだけです。

ローカルサイトとライブサイトのURLに変更し、「Go」ボタンをクリックすることを本当に〜してもよいですか?

Fixing WordPress images and broken URLs after moving to live site

これで完了です。これでローカルサーバーからライブサイトへのWordPressの移行は成功です。

うまくいけば、あなたのライブサイトはスムーズに稼働しています。エラーにお気づきの場合は、WordPressの一般的なエラーガイドをご覧いただき、トラブルシューティングにお役立てください。

この投稿が、WordPress をローカルサーバーからライブサイトに移行する際にお役に立てば幸いです。また、ライブサイトからローカルサーバーへの移行に関するガイド、または WordPress 移行の実践的な手順に関する究極のウェブサイト移行チェックリストもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

909件のコメント返信を残す

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. sam

    Isn’t it better to use a duplicator plugin instead of taking all this trouble as described in here
    or here
    I think using the duplicator is a easier. Feel free to add or correct me.

    • WPBeginner Support

      Yes, we have mentioned using Duplicator or BackupBuddy as the easier ways to do this in the article.

      管理者

  3. Louise

    Thanks so much for an excellent article – very straight forward and easy to understand.

  4. fadilah

    hi, i’m getting a problem with my permalink, my permalink is still pointed to my localhost something like fadil.dev so when i add a post/page, the permalink is pointed to my fadil.dev/?p=ID it should be pointed to fadil.com (my real domain) and not fadil.dev (my local domain) .. where i can find the configuration ? help me .. thankyou :)

      • fadilah

        my article/page works fine on the front-end, but the permalink on wp-admin when i added a new post/page appeared wrong , you can see my printscreen http://prntscr.com/2cfznc .. it should be terazam.com not terazam.dev

        • WPBeginner Support

          Seems like you didn’t change your site and home URLs either. Please follow all the steps mentioned above and your problem should get resolved.

        • fadilah

          i had changed my siteurl according to your instruction at 5th step before i asked this problem and my front-end issue was solved, thankyou :) … but it seems that when i changed the siteurl on wp_options table there was no effect with permalink on my wp-admin :(

        • fadilah

          SOLVED :)

          i found the config on Administration > Settings > General and you will find the “Site Address URL” and i changed it into the correct value. so WordPress Address and Site Address are different. i found it on wp documentation http://codex.wordpress.org/Moving_WordPress

          thankyou for your help :) have a nice day

  5. prox

    nice tutorial i was thinking to do and found your website luckily and also i would like to ask two thing

    1. what’s this footer advertisement option is it a plugin ?

    2 what’s the plugin your using for newsletter i saw when i enter to your site there’s nice pop up banner that saying do you want to lean about WordPress and then enter your email address

    please share if you don’t mind

    thank you

  6. Nathan

    Great help, thanks!

    One question, if I buy a theme, can I use it on both my local and live site even though they are different installations and thus have different WordPress id’s?

    I am building my first live site but I have set up a local to play with the designs and construct the content.

    Thanks.

    • WPBeginner Support

      Nathan, this is a theme licensing question and the themeshop you purchased it from would be better able to answer this. However, we don’t see any harm in that.

      管理者

  7. Deepo

    wonderful tutorial. complexity made simple

  8. Matt

    Hi. Firstly I’d like to thank you, this process was easy to understand and errorless on your end!

    My one hang-up was at the very end. I put in the SQL code in order to fix some linking errors, but must not have put the right local host because some small inconsistencies were not fixed. I have been using MAMP and accessing my site by going to “localhost:8888” Is this what I should put in that Step 7 code, or is there a different path?

    • WPBeginner Support

      Matt first you need to make sure that inside your wp_posts table you are using localhost:8888 inside post content. If yes, then use this in the step 7. If you are seeing all your links as localhost, then use localhost.

      管理者

  9. Dayomaks

    All instructions works fine, thanks, i am so glad, but the issue i am having now is importing my database…while trying to import my database to a live server i got these errors below:

    Error
    SQL query:


    — Database: `soundmode`

    — ——————————————————–

    — Table structure for table `xs_commentmeta`

    CREATE TABLE IF NOT EXISTS `xs_commentmeta` (

    `meta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
    `comment_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT ‘0’,
    `meta_key` VARCHAR( 255 ) DEFAULT NULL ,
    `meta_value` LONGTEXT,
    PRIMARY KEY ( `meta_id` ) ,
    KEY `comment_id` ( `comment_id` ) ,
    KEY `meta_key` ( `meta_key` )
    ) ENGINE = INNODB DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;

    MySQL said: Documentation

    #1046 – No database selected

    ANY ASSISTANCE ON THERE?

    • WPBeginner Support

      Check your database name, username, and password to make sure that you are using the correct settings to connect to your live site’s database.

      管理者

  10. Christie Bellah

    This worked great, thanks! In the past I had installed WordPress in the new hosting, dropped database tables, imported, etc. – this is so much faster and simpler.

  11. Stefano

    First of all, thanks for the tutorial – invaluable and well written.

    Unfortunately, I managed to get stuck anyway.
    I uploaded everything via filezilla and phpmyadmin, and when i try to go to my domain it doesn’t show up any error. But nothing else, either.

    Just a blank page – which is weird, because by typing /wp-admin at the end of the url i DO have access to the wordpress control panel, and every page seems to be all right.

    Sorry to bother, but I really have no clue about what’s happening..
    Thanks in advance!

    • Stefano

      Solved!
      Apparently, it had some issues with the theme loading.
      I couldn’t use the children theme i had worked on, but luckily I had changed just a couple of thing, so no big deal..

      • Stefano

        I did, and in fact the url worked (even if it showed just a blank page).
        I still have no clue about what happened, but setting up the theme again solved it.
        Lucky shot =P

  12. javed choudahry

    Hi
    Sir

    Thanku so much .This website is very good for wordpress learn and very help full .

  13. sesan

    please am having an error from step 4
    SQL query:


    — Database: `wordpress`

    CREATE DATABASE IF NOT EXISTS `wordpress` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

    MySQL said: Documentation
    #1044 – Access denied for user ‘Admin7393’@’%’ to database ‘wordpress’

    • WPBeginner Support

      Sesan, the export file prepared by phpmyadmin to import into your live site database, contains a line to check if a database exists if not then it tries to create it. To resolve this issue, you need to extract the zip archive you created. Inside it you will find a file with .sql extension. Open this file in a text editor like Notepad and then delete these lines

      CREATE DATABASE IF NOT EXISTS `wordpress` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

      Below this line you will see another line like this

      USE `wordpress`;

      Replace wordpress with the name of the database you are trying to import into.

      Save your changes and put the sql file back into a zip archive (if it is too big, other wise you can also import it as it is).

      管理者

      • sesan

        men you guys are d bomb it worked thank youuuuuuuuuuuuu!!!!!!!!!!!!!!

  14. Tyler

    Hi, thanks for the tutorial!

    I’m struggling with Step 2. Your tutorial shows several files/folders being uploaded whereas I only have wordpress.sql.gz from Step 1. I can’t seem to extract the file using any software but can open using a text editor.

    Any help would be greatly appreciated!

    • WPBeginner Support

      In the second step, you do not need to upload your phpMyAdmin export file (wordpress.sql.gz in your case). You need to upload your WordPress files which are located in htdocs or www folder of your localhost

      管理者

      • Tyler

        Thanks for the fast reply!

  15. Mario

    do I need a cpanel to do this procedure? I am using a plugin to backup and export databases already, unfortunately the host provider that the client is using does not have a cpanel.

  16. Rhomy Prama Dhieka (Web Designer)

    thanks for sharing.
    it help me alot migrating my wp website.
    would you mind if i translte this to my language, then i will put ur credit there ?
    thanks.

  17. ryan

    hi, i am using stablehost and have used them before with WP websites. I followed all your steps and I am getting a parked page from my hosting provider…

    • WPBeginner Support

      There can be several reasons for that. First make sure that you have installed WordPress in the root directory of your website. If you did then make a backup of your .htaccess file and delete the one from root directory of your website. If that doesn’t work, then find the default parked page files there might be an index.html file on your web server delete that file (Do Not delete index.php). If none of these help then contact your hosting provider.

      管理者

  18. Alex

    Thanks!

    I did a search for the ‘‹’ character in the extracted .sql file, but got an alert saying: The string ‘‹’ was not found.

    I don’t know if this matters, but I noticed that my local phpMyadmin version is 5.5.3, while my host’s phpMyadmin version is 3.5.8.2.

    Another note is that I had all my WordPress files already up on my public_html directory (which is your step 2) BEFORE exporting my local WordPress database (which is your step 1). I’m not sure if it makes a difference.

    I’ll try starting over with step 1, as you suggested, and if I get the same error then I may try the Duplicator plugin that you mentioned.

    Alex

  19. PatoPanichelli

    You really helped me. This step by step is awesome, I had no problems migrating from MAMP to a live site. Thanks

  20. Alex

    Thanks for the tutorial!

    Everything’s gone well until I get to the end of step 4. When I press the Go button at the bottom of the page, instead of having phpMyadmin import my WordPress database I get an error message that reads as follows:

    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‹’ at line 1

    Can you let me know what you think may be causing this?

    Alex

    • WPBeginner Support

      Alex, it seems like the database file you are trying to import has a character ‘‹’ which is not supposed to be there. You have two options to fix that, first option is go back to your localhost/phpmyadmin and export your local database again and then try to import it again. If the same error occurs again, then extract your database gzip file using 7zip program. Open the .sql file in a text editor like notepad and look at the first line. Also take a look at our database management using phpMyAdmin guide to learn more.

      管理者

    • Anna

      Make sure you clicked on the database name on the lefthand side that you’d like to import to. Make sure that is highlighted and then try again. (phpMyAdmin version 4.0.8).

  21. qs

    I get this error when I import datebase into live site. How do i solve it?

    Error
    SQL query:

    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

    /*!40101 SET NAMES utf8 */;


    — Database: `wordpress`

    CREATE DATABASE IF NOT EXISTS `wordpress` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

    MySQL said:

    #1044 – Access denied for user ‘bossaballsg’@’10.%’ to database ‘wordpress’

    • WPBeginner Support

      Try checking MySQL user privileges to make sure that the database user can perform these operations.

      管理者

      • Chathuranga

        Hi,

        Hope your DB name is “wordpress”

        Change the,
        – Database: `wordpress`

        CREATE DATABASE IF NOT EXISTS `wordpress` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

        change “wordpress” to your live DB name. It’s at your sql file.

      • qs

        I checked and all the privileges are already set to “yes”.

        is it because of the “latin1_swedish_ci” collation in my database? because the rest of the tables are all in “utf8_general_ci”

      • qs

        I checked and all the privileges are already set to “yes”.

        is it because of the “latin1_swedish_ci” collation in my database? because the rest of the tables are all in “utf8_general_ci”

  22. fab

    hi there,
    totally newbie here. hope you can help with this error message during step 4:
    Error
    SQL query:


    — Database: `information_schema`CREATE DATABASE `information_schema` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    MySQL said:

    #1044 – Access denied for user ‘renta730’@’localhost’ to database ‘information_schema’

    When setting this user I allowed all privileges to the database previously created (named “inicial”).
    Any thoughts?

    • WPBeginner Support

      You are not supposed to install WordPress in the database information_schema. Create a new database for your WordPress site, and continue from the step 4.

      管理者

  23. neha

    Hi,Nice tute,but can u plz tell how to change database name and password etc from wordpress from live server?

    • WPBeginner Support

      To change database username and password connect to your live website using an FTP client. Find wp-config.php file and edit it. You will see your database name, database username, and host information. Change it to the database information for your live site.

      管理者

      • Kerry O'Connor

        I’ve tried every variation of my ‘host url’ in the wp.config file and uploaded it every time, no avail, still getting ‘Error Establishing db..’

        Where before it was ‘localhost’, now it should be ‘mywebsite.com’, is that right?

        thanks

        • WPBeginner Support

          For MySQL hostname, localhost works fine for most user. However, if you don’t know your database host, then you can ask your web hosting provider.

  24. Manish Patel

    Good Explanation.We can easily setup from this tutorial.Nice Post.I have helpful it.

  25. Mohammadreza

    Best ever, I really appreciate your clear explanation. you’ve got your new follower for sure :)

  26. Changdeo Mhaske

    Thank You,

    would only make sense if this is a new site. If it is an existing site, then you would have to constantly comment out the hosts file in order to access the live site.

  27. Justin Esparza

    Thank you very much for this clear concise how-to. It helped immensely. You have a new follower.

  28. Satyanarayana

    Hi Dude.
    Actually i followed the process as you explaned above is very nice and clear.
    but i was getting the error “page not found”. when i click on link in a website
    i am changing my files from main server to localserver
    Can you please help

  29. Carol

    New to WP and completely lost. But I managed my first migration thanks to this article.
    Thank you! Thank you!

  30. Steve

    As a beginner, I found this article very helpful, but couldn’t get my site up live after developing locally. Everything was fine until Step 6. I did see the Error Establishing Database Connection error, and then edited the wp-config.php file. However, my site became a blank screen at that stage and I haven’t been able to change it.

    I continued on and went to my WordPress admin panel, and checked Settings » General. They still showed the localhost web address so I changed it to my site url. This is when things turned ugly. I was automatically logged out of WordPress and can’t get back in. In fact, when I ask WordPress to email me a new password to log in, its sends a localhost URL that takes me to a sign-on page with a message that reads “Sorry, that key does not appear to be valid.” I have no idea what caused that.

    Any help would be greatly appreciated.

    • WPBeginner Support

      Open your database in phpMyAdmin as mentioned in Step 5 and make sure that in wp_options table, your site url and home url options point to your live website.

      管理者

      • Steve

        Thanks for your suggestion. I double-checked and yes I had completed that step. Both have the correct URL

        Part of my confusion is that I now have two databases for this website. I originally had one accessible through a URL that starts with the number of an IP Address/phpmyadmin. Then I have the one I created in Step 3, which I did through my hosting company’s e-panel. They have different passwords and names. But I’ve tried both combinations in the wp-config file and still get the blank screen. Which one of these databases should I be using? They seem to have identical content.

    • Patrick

      Sparky!
      Your step-by-step guide was spot on. I am a mac user, and after MAMP, I am live now. Thanks a lot. It worked perfectly for me.
      Hat docked!

  31. Vishal Kumar

    I have done migration form live site to localhost successfully. But I noticed that Comment facility is not there after this. I have also checked all the option in ‘Setting->Discussion’ page. Everything is cheked but Commenting option and Leave comment box is not visible anywhere in the localhost. Please give me any suggestion for this because I am new in wordpress I am a Zend framework developer basically.

  32. NARESH

    Instead of moving the wordpress site, I would like to fresh install wordpress using fantastico or hostgator’s quick install, so will I be able to do like this too just by exporting and importing databases and uploading the themefiles? or this is the only way we can do it?

    I don’t know why. my local machine wordpress loads very slow than one, whichever is installed on live server using fantastico or quick install.

    • WPBeginner Support

      Naresh yes you can import your posts and comments using import/export tools in WordPress, then you can upload theme and other files using FTP. There are multiple ways to do things you need to choose one that works best for you.

      管理者

  33. Siddharth Khare

    Best Explanation Ever. I was able to set up in a mere 5-10 mins

  34. Mark Jones

    Do all of these instructions remain the same if there’s already an older, existing, non-wordpress page built where you want to move your wordpress page? For instance, rebuilding an existing site as a wordpress site, then switching over.

    • Editorial Staff

      Yes because in theory, you will be overriding everything that is there.

      管理者

    • Editorial Staff

      Thanks for leaving a comment Erwin. Yes, some others have recommended that tool as well in the comments.

      管理者

  35. Abrishca

    It’s easy to forget just how much work a good plugin really does for us – I personally use the Duplicator plugin to transfer new websites from my development server to the client’s domain and you can see how much time this plugin (and Backup Buddy) can save you.

  36. Praveen

    Hi,
    I am facing problem in changing the database after creating the new database.
    Is there any problem with my hosting service or anything else

  37. Iskandar Dzulkarnain

    thanks, your tutorial is solution for my problem

  38. Anna

    Are you reading my mind?! Just a little while back I sat down at the computer to figure out how to add a Facebook like button to my first website, currently in development. Whala! “How to add a Facebook like button to your posts” was that day’s article. Then I’m wondering how to begin the local to live migration today, and AGAIN, here’s this post! GET OUT OF MY HEAD! :)

    And seriously, thank you very much for the invaluable help you’ve given to a beginner like myself.

    • Editorial Staff

      Haha the little birdie told us that you needed this article ;) Glad to be able to help.

      管理者

  39. Jean

    Nice tutorial, thanks.

  40. riaz ali shah

    great article, the technique i often use for develop wordpress sites for clients, i use dummy text and images for local and then i move my theme only on server.

  41. John Coleman

    This was a great article. Another option to address the broken links issue is to do a find/replace on your .sql file (in a text editor) of the local URL to the production URL before you import it. This is also handy when moving a site to/from a sub-directory, or to push from staging (e.g. http://staging.domain.com) to production (e.g. http://www.domain.com).

    Thanks for putting this out there. I am sure it will help a lot of people.

  42. David

    Could have used this article 20 months ago. The trick I discovered in making the move was to open the database file in a good text editor. From there I did a search & replace maneuver to change localhost to the proper URL. It discovered numerous instances without me tracking down the tables, or worrying if my command syntax was correct.

    There’s a plugin called Broken Link Checker that’s worth running as well after the move.

    There are some web-hosting sites who’s infrastructure keeps everything in your WordPress site as localhost. No need to change anything in your local build. Just copy it over. Will definitely chose one of them next time.

  43. Mark

    2 suggestions to make it easier to move:

    1. When developing locally edit your HOSTS file (c:\Windows\System32\Drivers\etc\hosts) to point your domain name at local server. This avoids having to change the SITE URL and other links/images. Note: this will require config changes to your local web server.

    2. If you have to modify the SITE URL etc, after you have exported the local database and before import, Open the file in notepad and search for all instances of localhost/yourtestsite and replace with http://www.yourlivesite.com

    • Editorial Staff

      Mark,

      1. would only make sense if this is a new site. If it is an existing site, then you would have to constantly comment out the hosts file in order to access the live site.

      2. Yes that would make sense.

      管理者

      • Mark

        Changing the hosts file is something I do quite often and have a shortcut on my desktop giving me quick access.

  44. Gregg

    I also recommend DeskTop Server which I have been using for more then a year. Desktop Server allows you to create a local version of your site and then direct deploy it. Awesome!

  45. Sü Smith

    Great post! I typically just do find and replace on the .sql file with Notepad++ before uploading it to phpmyadmin. This is a nice alternative.

  46. Mike Ott

    Unfortunately this only works for some sites. A lot of wordpress plugins store serialised data in the database (Gravity Forms is one such plugin), and serialised data isn’t portable so doing an SQL dump and importing via PHPMyAdmin won’t work properly because of the string length differences between your local URL and live domain. You can’t even run an SQL query over serialised data.

    The best thing I’ve found to get around this problem is by using the WP Migrate DB plugin (http://wordpress.org/plugins/wp-migrate-db/). It handles the serialised data problem flawlessly every time and you won’t have to do half the other things you mentioned in this post.

    Have fun.

    • Mark

      Just had a light bulb moment! I have run into this issue before, thanks for the heads up Mike and pointer to the plugin,

    • Augustas

      For replacing paths and URLs I always use “Search and Replace” tool ( http://goo.gl/MCsKl ). It replaces serialized data, and it can be used for other CMSs as well, not only for WordPress.

  47. estudiowp

    Nice article an well explained steps!

    However, many people will find troubles in their migrations because of the serialized data.

    Some plugins and themes use serialized data, and the replaces in step 5 and step 7 won´t change all the urls and paths that need to be changeed.

    For those steps you could use these tools or plugins:

    · wp migrate db plugin: http://wordpress.org/plugins/wp-migrate-db/

    · search and replace tool: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    I hope this comment will be useful and sorry for my english!

  48. RW

    awesome post! I could have used this with my first local > server migration!

  49. Jean

    Great article – best I’ve read on this subject.

    I moved a site a while back and the only thing I would add is that you might need to re-save the permalinks settings. I had to do this because none of my menu links worked so this was an easy fix (luckily!)

    • Mike Ott

      If anyone wants to know what that happens, it’s the .htaccess file shows a different RewriteRule between local and live.

      A quick edit to .htaccess fixes the problem or as Jean pointed out, re-saving the permalinks settings will also do the trick as it’s just fixing the RewriteRule.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。