Perform a MySQL Database Dump from a Remote Server to Your Local Machine Using DBeaver

Abinav Ghimire
readytowork, Inc.
Published in
4 min readSep 29, 2023

As a developer, we face different types of bugs and errors, and if these bugs and errors are related to our data in the database, then we need to get our hands dirty and get deep into the database schemas. This is fairly doable if the data persists on our local database where we can manipulate the data but what if the data persists remotely and debugging needs to be on that data? Changing data on the remote database can be extremely risky and solving the problem gets much more difficult. Database backups also play a pivotal role in maintaining data integrity and ensuring disaster recovery. Hence, in order to make the debugging process easy and to play around with the production data, we need to dump the remote database to our local machine which we see how to do in this article.

For this article, we will be using Dbeaver which is a free SQL client that is used to connect to databases such as MySQL. DBeaver is available in Windows, Linux, and macOS.

How to Dump the Database?

First, we need to ensure that we have access to the remote MySQL server that we intend to back up. Make sure to have the necessary credentials server host, username, password, database name and server port in order to connect to the remote database, if you don't have the credentials, then ask the database administrator to provide it to you or to provide the dump file directly.

Once we have the credentials, we can use Dbeaver to dump the remote database on our own following the below steps in order:

  1. Open Dbeaver
  2. In DBeaver, click on the “Database” menu, then select “New Database Connection.”

3. In the “Select a driver and data source” dialog, we will choose MySQL from the list of available database drivers and click “Next.”

4. Configure the connection settings for your remote MySQL server using the credentials of the remote database. Once you’ve entered the connection details, click “Test Connection” to ensure it’s working, and then click “Finish”. In the DBeaver main window, you should now see your MySQL connection listed in the Database Navigator on the left.

5. Now, in the databases navigation panel, right-click on the newly connected database and select the Dump database option in the tools sub-menu.

6. In the new pop-up, configure your export options. Here are some of the options you may consider:

  • Output Location: Specify the directory where you want to save the database dump file on your local machine. Ensure that you have write permissions for this directory.
  • Tables to Export: Decide whether you want to export specific tables or the entire database.
  • Advanced Options: Explore advanced settings such as export mode, character set, and more, based on the demands of your project.
  • Monitoring the export: DBeaver will display real-time progress information for the export operation, so look for any error from time to time during the export process.

Finally, do not forget to verify your dumped database.

Import the dumped file

If you need to restore the database on your local machine, you can use the MySQL command-line tool to import the dump. For example, you can employ the following command to import the dump into your local MySQL server:

mysql -u username -p database_name < dump_file.sql

Ensure that you replace username, database_name, and dump_file.sql with the appropriate values for your setup.

We can also import the dumped file using Dbeaver. Firstly, we need to create a new database connection that connects to our local MySQL server.

Note: You might need to set the password that you used while installing MySQL in your local machine.

Finally, create a new database in the newly created local database server and right-click on the newly created database to import the dumped database.

There you go! You have successfully performed a MySQL database dump from a remote server to your local machine using DBeaver.

Conclusion

Performing a MySQL database dump from a remote server to your local machine using DBeaver is a crucial skill for database administrators and developers as you can ensure data preservation, backups, and recovery for your MySQL databases. Performing regular database dumps is a best practice to safeguard your data and ensure business continuity in case of unexpected issues or data loss incidents. This will also help you to debug your application without any risks of data loss. So be sure to perform database dumps to minimize risks of data loss and corruption.

--

--