Use Virtualmin to Import/Restore a MySQL Database

Virtualmin is a feature rich control panel to manage your VPS. It gives you an option to import SQL dump file (Database backup file) into MySQL database directly from its MySQL module. This means that you don’t have to install phpMyAdmin on your server just to import an MySQL backup file into a database.

Downloading the SQL dump file and importing it to the new server is an important part in server migration. You might be migrating from shared hosting to a VPS that has Virtualmin installed. Or migrating from managed VPS to unmanaged VPS to cut the cost. In either way, you should migrate your files and databases over to the new server. If your new server is built with Virtualmin or you used my Virtualmin and Nginx on an unmanaged VPS tutorial, you can use this method to import your database backup file into MySQL database. You can find the video how to at end of the page.

What is a SQL Dump file?

All your posts, pages, comments, email address you use to login to your website and even your password is stored in a MySQL database. When you export an MySQL database with phpMyAdmin or another software, it creates a file with all those information with .sql extension. This is called SQL dump file. Importing this file to a new database will import all your posts, pages, comments and your login info to new database.

If you don’t have the backup file yet, you need to create it now. Watch how to back up MySQL database with cPanel/phpMyAdmin for more information on that.

How to import SQL dump file using Virtualmin?

As I said before, you don’t need to install phpMyAdmin on your server just to export and import MySQL databases. Virtualmin got it covered. Although installing phpMyAdmin with Virtualmin is just one-click away.

Let’s start the process by login in to Virtualmin as root. Once you’re in, switch to Virtualmin tab from top-left corner. Make sure correct domain is selected and click Edit databases. Click Manage under the database name you want to import the SQL file to. Click Execute SQL from the page that loads next.

You’ll be taken to the Execute SQL page where you have few options to execute SQL queries. All of the options on that page can be used to import SQL database into the server. But the option we’re going to use today is on the Run SQL from the file tab. So switch to it. Tick From uploaded file and use attachment icon to browse your computer and select the SQL dump file. Then click Execute to import SQL file to the database.

Your database backup file will be uploaded in the background. It’ll take some time depending on the size of SQL file and your connection speed. The next page will display errors if there are any. If not, it’ll display No output generated. If you see this, your SQL files is successfully imported to the new database.

The Video Tutorial

The video on the top shows you exact method of importing SQL dump file into MySQL database using Virtualmin.

That was easy right? Well it’s easy for smaller SQL files. Sometimes SQL dump files can be few GBs large. In those cases it’s best to upload it to server using ftp or sftp first and then using From local file option on the Execute SQL page to import it. Uploading files with a ftp client is more stable than using your browser to upload. Specially when it comes to large files.

So I hope you can successfully restore your MySQL database backup into a new database using Virtualmin execute SQL option. If you are having trouble importing, let me know on the comments section. I’ll try to help.

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Related Articles

3 Comments

  1. Great tutorial. On my last website (while migrating from CWP) I have use this method. Much more secure in my opinion, especially if there is no intend to use phpMyadmin after initial setup.

    I still don’t understand why phpMyadmin must be installed in a folder inside /public_html (Virtualmin) and be easily accessible in that way.

Leave a Reply

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

Back to top button