How to import database in MySQL from Windows machine to my DO droplet

March 21, 2019 905 views
MySQL Databases CMS Joomla CentOS

Hi,

I have a Joomla website which I need to migrate from shared hosting to DO droplet having CentOS 7 installed on it.

I have already taken the whole website backup including the database on my Windows 7 machine.

I have tried to create the necessary environment by installing Apache, MySQL, PHP.

I have also created an empty database and the username having the same name as that in the configuration.php file.

Now, before i move Joomla files to a new location, I need to have the newly created empty database replaced/restored/populated with the old(backed-up) database.

So, how do I migrate and restore that database to DO droplet?

I am using Putty as an SSH client to connect to my DO server.

1 Answer

Greetings!

You can upload the backup file for the database and import it over command line. On Windows, perhaps SFTP using FileZilla would be the easiest way:

https://www.digitalocean.com/community/tutorials/how-to-use-filezilla-to-transfer-and-manage-files-securely-on-your-vps

Now let’s say you’ve ended up with a file named “backup.sql” in /root, and you want to import it to your new database which I’ll assume is named “joomla.” In that case, over SSH I would run this:

mysql joomla < /root/backup.sql

Then you’re done :)

Jarland

by Pablo Carranza
This article will teach you how to use Filezilla to transfer and manage files securely on your VPS.
  • @Jarland…Are you sure the syntax of the command is correct?

    I get this error

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 
    

    Thank you

    • Nothing wrong with the syntax. My mistake. I didn’t get it initially. I was running that command on MySQL prompt and hence the error. Ran the command from the host, was presented with Permission denied error.

      I think there is something I have done seriously wrong.

      I will post all the details regarding what/how I have done with the system in the next post.

Have another answer? Share your knowledge.