How do I import a Wordpress database?

Posted April 8, 2018 8.9k views
WordPressLEMPUbuntu 16.04

I have downloaded a database from an existing Wordpress installation from another server. I would now like to import the database into a new Wordpress installation in my droplet.

I have uploaded the file to: /var/www/website/_downloads/

Any help would be greatly appreciated, thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

If you are installing the database through the terminal;

  1. open the console and use the interactive MySQL mode

use <name_of_database>;

source <path_of_.sql>

first take the backup of wordpress database from another server using below command

mysqldump -u root -p databasename > database.sql #it will create file database.sql in current directory.

Not copy that file to new server and use below command to import the database.

mysql -u root -p databasename < database.sql

you can also unzip the /var/www/website/_downloads/ file and directly import using below command.

mysql -u root -p database name < /var/www/website/_downloads/database.sql

provide the root password to complete import.