Since I'm making a full backup of my entire debian system, I was thinking if having a copy of /var/lib/mysql
directory is a viable alternative to dumping tables with mysqldump.
Rename the /var/lib/mysql folder, e.g. to /var/lib/_mysql. Copy the old /var/lib/mysql folder from the old Debian (LMDE) system. sudo systemctl start mysqld . -> Job for mysqld.
Usually /var/lib/mysql or /var/db/mysql directory used to store database and tales under UNIX like operating systems. You can use the following command to locate MySQL datadir: grep datadir /etc/my.cnf. datadir=/var/lib/mysql. Or.
To avoid getting databases in a inconsistent state, you can either shutdown MySQL or use LOCK TABLES and then FLUSH TABLES before the backup. The second solution is a little better because the MySQL server will remain available during the backup (albeit read only).
This approach is only going to work safely if you shut the database down first. Otherwise you could well end up in an inconsistent state afterwards. Use the /etc/init.d/mysql stop command first. You can then restart it after the backup is taken.
It's perfectly OK as long as you shut down the MySQL sever first and use exactly the same version to retrieve the "backup". Otherwise it isn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With