1

I want to move my wordpress dir form my development environment to my production environent. The thing is that my production environment is an ongoing blog were I want to use the posts thats on my blog and not the fake posts on my development environment.

So I want to use my old database and not the one I have in my development environment. Is this possible? And how do I do this?

Edvard Åkerberg
  • 2,181
  • 1
  • 26
  • 47

2 Answers2

2

I will walk you through this step by step.

  1. Create a copy your production environment on your development environment.
  2. You will need to export/import your production server MySql database via phpMyAdmin. For a good tutorial in how to do this, go to: https://mediatemple.net/community/products/dv/204403864/export-and-import-mysql-databases
  3. Using phpMyAdmin on your dev database, export all rows from every wp_ table, excluding the wp_posts table.
  4. From your dev/production database, import all rows in to the appropriate tales.
  5. Test your dev/production site for errors or problems.

It is likely that some of the rows in the wp_posts table has data not related to just Wordpress Posts. You will need to identify these as well by running a SQL query, such as:

SELECT * FROM wp_posts WHERE post_type='some_id'

Breaking down the SQL query for you:
[SELECT *] Select All
[FROM wp_posts] From the table "wp_posts"
[WHERE post_type='some_id'] 'some_id' is associated with a post type.

Themes, plugins and other functionality are often extended through:
wp_posts table -> post_type='some_id'.

The default value for Wordpress posts is: post_type='posts'.

Rows within the wp_posts table that DO NOT have the
post_type='posts'
value should be migrated over to your production server.

References:
Wordpress Database:
https://codex.wordpress.org/Database_Description

MySql Select a Row Query:
https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row

Wordpress Database Diagram:
https://codex.wordpress.org/images/2/2a/WP3.9.4-ERD.png

Export and Import MySql
https://mediatemple.net/community/products/dv/204403864/export-and-import-mysql-databases

Connecting to a Wordpress Database with wp-config.php
https://codex.wordpress.org/Editing_wp-config.php

Mike Stratton
  • 463
  • 1
  • 7
  • 20
0

If they are on the same host, you can change the database through the wp-config.

You have to change this settings:

define('DB_NAME', 'dabname');

define('DB_USER', 'dbuser);

define('DB_PASSWORD', 'dbpass');

define('DB_HOST', 'localhost');

Community
  • 1
  • 1
Filipe Coutinho
  • 101
  • 1
  • 7