Importing MySQL dump of WordPress database from terminal

  1. Dump the orginal MySQL database, and put it into the folder you’re working in on the new server.
  2. Create a new databse with a new name.
  3. Create a new user, with the same user name and password used in the orignal wp-config.php file.
  4. Grant that user full access to the new database
  5. Flush privileges and exit

Run the import command: mysql -u dbusername -pdbpassword dbname < mysqldump.sql

I made a new database, with a new name. Then I created a duplicate user and password as used in the original database. Then I imported. And boom! MySQL imported!

Note

This process is especially helpful if you are moving WordPress installations from one server to another. It will have you time and avoid having to deal with PHP MyAdmin, etc. Once you database is imported, but add your mysql credentials to the wp-config.php file. If you are hosting the database on your server, it’s probably localhost, if not just set your remote host.

Trouble Shooting

If you ever perform this process, successfully importing the mysql database, but when you visit the site, all of the content is missing or WordPress keeps loading install.php, you may have forgotten to set the data table prefix. Your table_prefix, typically found in the wp-config.php has to match the old database.