How to import MySQL .SQL dump/backup files to MySQL Server

We’ve recently created a WordPress site and we want to move the database for this site from our production server to our Remote MySQL Server. To do this we need to take a copy of the database and import the .SQL MySQL file on our remote database server. So there are two ways to get a copy of your database, via the GUI if you use cPanel or DirectAdmin. Or via the command line using a console.

Download MySQL Database

Let’s get a copy of the database. If you use cPanel or something with PHPmyAdmin then you can easily export the database which will download a .sql file to your computer. For the purpose of this guide, we have exported our database and placed it in our public_html. We can then use wget to grab a copy of it. We’re assuming you already have a copy of your database in .sql format on your database server

To download a dump or copy of your MySQL database via the command line you can use the mysqldump command in the console. State the database user and the database name. Where you would like the database backup to be placed on your NVMe VPS Instance.

mysqldump -udb-user -p datab > database-dump.sql

Import MySQL .SQL Dump File

So, our exported MySQL database is called deltasq_wp114.sql. We are going to import the .SQL dump to a database we have already created on our MySQL server. The database is called deltadbbeta. So let’s import the database.

mysql -u username -p database_name < deltasq_wp114.sql

We specify the username of the MySQL user, the MySQL database name and the file name of our exported database. The instance will now import the sql file to your database.

stage@command:~# mysql -u delta -p deltadbbeta < deltasq_wp114.sql
Enter password:

Next, you can now update your MySQL database details in any software programs like WordPress. That is the process of importing a database dump to a MySQL database.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button