Migration: Copying database content to a different server

I’m migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least I don’t have access to it), so I need to copy the dump using console. Or maybe there is some WordPress plugin for this?

Thanks in advance!

Related posts

Leave a Reply

4 comments

  1. You can import the database in your server’s shell easily. Just export the current database into a .sql file, upload it to the new server, SSH in and cd into the directory with the .sql dump of your old database and run this.

    mysql -u your_mysql_user -p your_database < ./your_sql_file.sql
    

    As Brian Fegter pointed out, you can also dump the file in from your old server. Add the old server’s IP to your new servers whitelist and run the following from the old server’s shell:

    mysql -u your_mysql_user -p -h new_server_host database_name < /path/to/sql_file.sql
    

    Both will prompt your for a password then run.

    If you just need the content, use the WordPress exporter, which will require 100% less command line fu.

  2. You could do a migration directly from your old server to your new server without download/uploading a large sql dump. You can contact your new host to have them whitelist the old server IP for remote mysql.

    Then, run this on your old server.

    mysqldump -u user_name -ppassword -h new_host_address db_name < /path/to/sql_file.sql 
    
  3. PHPMyAdmin is pretty common if your hosting company does not have it installed for you, I would send them the dump and ask they do it. Otherwise using Navicat you can pretty much drag and drop from one database to another and copy all the data.