skip to Main Content

Somewhat of an amateur here: I moved a wordpress site from one host to another. This involved me backing up the old site, and uploading all of the material from the wp_content folder into the wordpress installation on the new site via FTP. When I log into wp-admin, I can see the transferred plugins and themes, but not the pages. I’m guessing this has something to do with me needing to properly edit the wp-config file to point at the correct database. The database is currently sitting in the wp-content folder and simply called ‘database.sql’. Could someone kindly explain where this database should sit, what it should be called, and what updates I need to make to the wp-config file please?

3

Answers


  1. At this point, as you said being an amateur, I think the easiest way for you to migrate a website from one host to another is using a plugin, which makes the migration way easier.
    Try something like – All In One WP Migration, or Duplicator plugin

    Besides that it seems that you have not migrated the Database. Just migrating the wp-content folder does not do the job.

    I assume you already have an working application in the server. You need to do the following:

    1. Locate the phpMyAdmin or a db manager in you hosting website.

    2. Create a new database(name, username, password and host(usually localhost). Save those values because you need to edit them later in wp-config.php file.

    3. In phpMyAdmin select the db and find the import tab and upload the database.sql file you had.

    4. Now you should edit the wp-config.php file of your new wordpress installation directory. This meaning updating the following lines:

      define(‘DB_NAME’, ‘your_database_name’); // Replace with the new database name

      define(‘DB_USER’, ‘your_database_user’); // Replace with the new database username

      define(‘DB_PASSWORD’, ‘your_database_password’); // Replace with the new database password

      define(‘DB_HOST’, ‘localhost’); // Replace if the database host is different

    5. Sometimes the URL also need updating in database. Test, if it needs, then go to phpMyAdmin and open the wp_options tabe, look for the rows with option_name values of you siteurl and update their value to match your new site’s URL.

    Let me know if this works for you or you need some more information.

    Login or Signup to reply.
  2. You need to import the database file in phpmyadmin.

    First create database in MySQL in your hosting
    Then Create new user and link with database
    now open PhpMyAdmin and click on database that you created and import database backup file in it using import option.
    And finally change db name and user name & password in config.php file.

    Login or Signup to reply.
  3. To get your WordPress site running correctly after transferring it, the database is a critical component. If you see your plugins and themes but not your pages, it’s likely because WordPress can’t access or find your database properly.

    Here’s a step-by-step guide to resolve this issue:

    1. Import the Database
    Your database.sql file is a backup of your WordPress database. It needs to be imported into a database on your new hosting environment.

    Steps:

    1. Log in to your hosting control panel (e.g., cPanel, Plesk, or similar).
    2. Open phpMyAdmin.
    3. Create a new database:
      • Go to the Databases section and create a database (e.g., wordpress_db).
      • Create a database user and password, then assign the user full privileges to this database.
    4. Import the database:
      • Select the new database in phpMyAdmin.
      • Click Import.
      • Choose the database.sql file from your computer and click Go to import it.

    Now your database is uploaded and ready to be used by WordPress.

    2. Update the wp-config.php File
    The wp-config.php file connects WordPress to your database. You need to update it with the correct database details.

    Steps:

    1. Connect to your site using FTP or your hosting file manager.

    2. Open the wp-config.php file in the root folder of your WordPress installation.

    3. Look for these lines:

      define(‘DB_NAME’, ‘database_name_here’);
      define(‘DB_USER’, ‘username_here’);
      define(‘DB_PASSWORD’, ‘password_here’);
      define(‘DB_HOST’, ‘localhost’);

    4. Replace the placeholder values with the details for your new database:

    • DB_NAME: The name of the database you just created (e.g., wordpress_db).

    • DB_USER: The username assigned to the database.

    • DB_PASSWORD: The password for that database user.

    • DB_HOST: This is usually localhost for most hosting providers. If your host uses a remote database server, they will provide the correct hostname.

      define(‘DB_NAME’, ‘wordpress_db’);
      define(‘DB_USER’, ‘wp_user’);
      define(‘DB_PASSWORD’, ‘yourpassword’);
      define(‘DB_HOST’, ‘localhost’);

    Save the changes and upload the updated file back to your server if you edited it locally.

    3. Verify the Database Connection
    After updating the wp-config.php file:
    1. Visit your site and check if it loads properly.
    2. Log in to your WordPress admin panel and ensure all pages, posts, and settings are restored.

    4. Update URLs in the Database
    If the old site had a different domain or URL, you need to update the database to reflect the new domain.

    Steps:
    1. Install a plugin like Better Search Replace.
    2. Search for the old domain (e.g., http://oldsite.com) and replace it with the new one (e.g., http://newsite.com).
    3. Run the search-and-replace operation, ensuring all URLs are updated.

    you can use an SQL query in phpMyAdmin:

    UPDATE wp_options SET option_value = replace(option_value, 'http://oldsite.com', 'http://newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    
    UPDATE wp_posts SET guid = replace(guid, 'http://oldsite.com','http://newsite.com');
    
    UPDATE wp_posts SET post_content = replace(post_content, 'http://oldsite.com', 'http://newsite.com');
    
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldsite.com','http://newsite.com');
    

    5. Refresh Permalinks
    Once the site is accessible, update your permalinks to ensure pages load correctly.

    Steps:
    – Go to Settings → Permalinks in the WordPress admin dashboard.
    – Click Save Changes to refresh the permalink structure.

    6. File Placement for the Database
    The database.sql file does not need to stay in the wp-content folder. Once you’ve imported it into your database through phpMyAdmin, you can delete it from the server to prevent unauthorized access.

    If you follow above steps, your WordPress site should work properly on the new host.
    Please let me know if you encounter any issues.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search