1. Welcome to DNTrade. If you want to find out about the latest domain name industry news or talk, share, learn, buy, sell, trade or develop domain names - then you've come to the right place. It's a diverse and active community, with domain investors, web developers and online marketers - and it's free! Click here to join now.
    Dismiss Notice

Moving WordPress from One Host to Another with cPanel Access

Discussion in 'Guest Articles' started by chris, Jan 20, 2016.

  1. chris

    chris Administrator

    Joined:
    Mar 7, 2010
    Messages:
    2,253
    Likes Received:
    829
    auDA Member:
    Yes
    This article was written by DNTrade member @johno69 (Paul), the founder and project manager at Illawarra Web Design. Paul has been working in web development for over 12 years. A big thanks to Paul for sharing this!

    ---

    Moving WordPress from One Host to Another with cPanel Access

    I often get asked this question, how can I move my WordPress website from one host to another?

    Generally a cPanel transfer from the old host to the new host will work for you and you can contact your new host and ask them to help with that.

    There are often reasons why that is not the best way to go. Are you wanting to move a site you have set up as an addon domain but want to leave the root site where it is? that’s just one reason you will need to do this manually. So here are some steps to help.

    Today i’ll go through the steps for you if you DO have cPanel access to the old server. Later I will cover how to do the same without cPanel access the the old server.

    Essentially it’s just a matter of backing everything up, and moving it. Sounds easy right? Well it’s easy when you know how.

    Because you are not changing the URL there are no real changes you need to make to any settings before backing up.

    Step 1: Back up the files.

    In cPanel go to File Manager, in the public_html folder, select all, compress.

    [​IMG]

    Then it’s just a matter of downloading the zipped file.

    Step 2: Export the Database.

    We need to log in to phpMyAdmin for this one. Once you are in phpMyAdmin, select your database from the databases on the left. Once you have the database tables visible, simply click the Export button at the top.

    [​IMG]

    From the next screen you will need to complete the export, and download the file.

    [​IMG]

    Now we have everything we need to move the site to the new host.

    Step 3: Uploading the files

    On the new server, you need to go back into file manager and upload the zip file you downloaded before. Then extract the zip file into the public_html folder.

    Step 4: Create a new Database

    On the new server, within cPanel, go to MySQL Databases and create a new database. Write down the database name.

    Create a database user, write down this name and password too.

    Add the database user to the database and give them all privileges.

    [​IMG]

    Now we have a new database, new database user, new database password.

    Step 5: Import Database

    In just the same way we exported the database on the old host server, we now complete the import into the new database on the new host server.

    Go into phpMyAdmin on the new server, select your new database, click Import.

    Simply browse for the SQL file you downloaded before, and import.

    [​IMG]

    Step 6: Link new Database to WordPress.

    There is one file that you need to edit to tell WordPress you now have a new database.

    In file manager in cPanel (new server), click on wp-config.php and then edit, you will need to update the database name, username & password to be the ones you set up on the new server database when you created it.

    [​IMG]

    Step 7: Update your Domain Name Servers

    The last step is just that, head over to your registrar and update the DNS of your domain name to point to the new server.

    Now once the DNS has propagated you will have your website on the new server.

    Finishing Tip

    As a note, you may want to log in to the old server website and make a post, or change some text on the old server AFTER you complete the move, but before you change the DNS to be able to tell when the DNS has changed over. I usually just add an extra word into the content or something similar.

    Happy moving!
     

    Attached Files:

  2. Christopher

    Christopher Membership: Community

    Joined:
    Jun 13, 2014
    Messages:
    467
    Likes Received:
    178
    Great explanation @johno69 !
    I read that allowing all privileges to the database wasn't a good idea for security, is that true?
    and
    Am I correct in thinking this doesn't move the emails that are in my account over to the new account either and I have to move them another way?
     
  3. Joel

    Joel Membership: Community

    Joined:
    Oct 26, 2011
    Messages:
    345
    Likes Received:
    75
    The method listed above is great for moving the site by itself. It doesn't move anything else on the hosting account, including email accounts, forwarders, other MySQL databases, etc.

    If you wish to move email accounts and you're on cPanel, it's super easy by using the built in cPanel transfer tools. Using this method you'll probably only need to update nameservers to get it back up and running.
     
    chris and Christopher like this.
  4. Christopher

    Christopher Membership: Community

    Joined:
    Jun 13, 2014
    Messages:
    467
    Likes Received:
    178
    Thanks @Joel very useful.
     
  5. helloworld

    helloworld Membership: VIP

    Joined:
    Apr 21, 2012
    Messages:
    1,116
    Likes Received:
    165
    Cpanel back up wizard seems like an easier option.

    I would add a Step 6A

    Test your Site
    Now that you have moved your website across to your new web host you will want to check it is working before updating your Nameservers so that you can check and fix any errors that may have occurred during migration.

    In Windows go to C:windows/system32/drivers/etc/hosts
    Open the hosts file
    At the bottom add the following line
    123.123.123.1 www.yourdomain.com.au

    Replace the above numbers with the IP of your new server and replace yourdomain.com.au with your domain name. Save file.
    Note: If you do not run your PC as an Administrator then you may get an privilages error. To get around this without booting as Admin, simply go to notepads location either in start menu or in your program files, right click and run as administrator.
    Copy the content of the host file and save to the above location.

    If you do not know the IP address of your new server these details are normally found in your Account Information email or on the left hand side of Cpanel. If you do not have either of these, go to search on your Computer and look for CMD. This will open dos.

    Type ping website address (normally the server address they gave you)

    Once you have tested your site and it is working update Name Servers.
     
    chris and Christopher like this.
  6. johno69

    johno69 Membership: VIP

    Joined:
    Nov 29, 2008
    Messages:
    2,664
    Likes Received:
    422
    auDA Member:
    Yes
    This is generally too advanced for most users just looking for a simple method.
    I've done this many times over with my eyes closed now.
     
    Christopher likes this.
  7. helloworld

    helloworld Membership: VIP

    Joined:
    Apr 21, 2012
    Messages:
    1,116
    Likes Received:
    165
    Well i think if they're up to moving the site then they are probably up to doing some testing first. Each to there own though
     
    Christopher likes this.
  8. Joel

    Joel Membership: Community

    Joined:
    Oct 26, 2011
    Messages:
    345
    Likes Received:
    75
    I would tend to agree. It's not complicated if you know what you're doing but I've found most people don't!
     
  9. Christopher

    Christopher Membership: Community

    Joined:
    Jun 13, 2014
    Messages:
    467
    Likes Received:
    178
    All the same good article, I'm doing a site rescue right now, for a client (freelancer) and their client is on plesk, arrgh! The basic principals apply, backup all files, backup databases, There's no cpanel here. I'm not moving the site either But its definitely worth knowing how to backup, and restore, out side of WordPress. I do agree its worth testing, before switching the dns.
     
  10. Oz.

    Oz. Membership: VIP

    Joined:
    Jan 29, 2010
    Messages:
    753
    Likes Received:
    29
    For migrating a wordpress DB I recommend using the free WP Migrate DB plugin. It has an option to automagically do a find and replace on any file paths (eg: home/old_site/public_html > home/new_site/public_html) and URLs and handling serialised data that you specify.

    Then you simple import the resulting zipped sql file with phpmyadmin or whatever you normally use.
     
    chris and Christopher like this.