Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to export a MySQL database.

November 17, 2017 by Albert Valbuena

You are your website editor, owner and now administrator. You want control over the whole process and you are migrating from a managed site. Or you are a versed user on unix-like environments and you are just willing to export your database. This is a simple post on how to export a MySQL database.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

One thing you have to know before you accomplish this task is the following. PhpMyAdmin is not the best solution to export a MySQL database whatsoever for big DB’s. Don’t get scared though. PhpMyAdmin is a great tool to import and export databases for many sites, but it’s got its limitations. It is known and reported by the developers themselves it can miss behave with databases bigger than 50MB. So there are only two alternatives left. Grab a backup from your hosting provider. Or dig into the terminal. The first one is easy so anyone will know how to do this. Let’s do the second option.

SSH into the remote server. Once in, you will use a command called mysqldump. The dump command is an old one and a very well known for the old UNIX admins. Mysqldump basically extracts (dumps) the whole content from a database into a file. For more information read the documentation.
The command basically goes as:

myslqdump -u (username here) -p (databasenamehere) > outputilfe.sql

Before that make sure nothing is being written on this database. This may require locking the DB down or deviating the writes to another replica DB which will be the master when you are dumping the slave, if you happen to have a high volume site. And yes there is a solution for this if you read the MySQL manual so you can avoid a secondary DB.

So now you are finish the task: export a MySQL database.  After that you will copy the database to the new host. Or you can also back it up in doing this and storing it wherever you may like. Mind the longest operation will not be exporting the database but importing it. Consider this if your database is big. For the low hundreds of MB databases this won’t take longer than a few minutes.

Use this link to get 100 $ credit at DOcean and support Adminbyaccident.com hosting costs.

Filed Under: How To's, How To's

Recent Posts

  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall
  • How to install Matomo 4 on FreeBSD
  • How to test SSL/TLS configurations
  • How to configure Apache HTTP as a reverse proxy on FreeBSD
  • How to install Nextcloud on FreeBSD 12
  • How to install ModSecurity 3 on FreeBSD
  • How to replace a disk on a ZFS mirror pool
  • How to install Webmin on FreeBSD 12
  • How to patch OpenSSH in FreeBSD 12.2
  • The CentOS party is over, isn’t it?
  • Donation Time 2020
  • How to configure TLS 1.2 on UNIX or GNU/Linux

Archives

  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall
  • How to install Matomo 4 on FreeBSD

Copyright © 2022 · Magazine Pro Theme on Genesis Framework · WordPress · Log in