1

I used to rely on XAMPP in my Kubuntu 18.04 which located in /opt/lampp. I uninstalled the XAMPP and had a whole folder backup in this directory before that, and eager to install all the LAMP stack individually, which i installed apache2, mysql-server, and phpmyadmin after that.

The thing is, i want to import my databases from my backed up XAMPP folder located in /opt/lampp/var/mysql which consist of all my databases with tables in .frm and .ibd format, which is obviously exist, to my current installed mysql package database location in /var/lib/mysql.

After i moved those databases, i opened phpmyadmin to make sure the dbs imported correctly, but i only saw the database without the table inside the database. How come? What needs to be done to restore the tables inside?

Vicky Sultan
  • 73
  • 2
  • 15
  • 1
    give this a try https://dba.stackexchange.com/questions/16875/restore-table-from-frm-and-ibd-file – nbk Apr 11 '20 at 18:17

1 Answers1

0

You can't just copy database files from the datadir (/var/lib/mysql in your case). A proper MySQL/MariaDB backup is to generate .sql files which you can then import independently. It's not possible to selectively restore certain databases, due to the way certain files are managed (such as ibdata1 and perhaps others such as logfiles).

What I would try, and may or may not work, is this (the usual disclaimers about backups apply, I'm not responsible if your system becomes inoperative or catches fire, etc):

  1. Make a back up of your existing databases (to SQL, I use the mysqldump command-line utility that ships with MySQL/MariaDB).
  2. Stop the MySQL daemon and make sure it isn't running.
  3. Temporarily move your current datadir out of the way (perhaps with a command like mv /var/lib/mysql /var/lib/mysql-current).
  4. Copy your complete backup, the entire MySQL datadir (from XAMPP's old /opt/lampp/var/mysql), to /var/lib/mysql.
  5. Start the MySQL daemon.
  6. Connect and export any data you wish to save to SQL files.
  7. Stop the daemon.
  8. Move the current /var/lib/mysql out of the way (or if you're brave, delete it entirely).
  9. Restore your original files from /var/lib/mysql-current to the original location in /varlib/mysql
  10. Start the daemon again
  11. Import the SQL files you've generated from step 6.

That's it — you should now be all set with your original data in your new database.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
  • The problem is i cannot access my old databases on XAMPP phpmyadmin, it says some sort of Table doesn't exist in engine while it clearly showing the tables inside the databases. So i cannot dump my databases i think – Vicky Sultan Apr 13 '20 at 02:28
  • Did you do all of the steps, including stopping the daemon and first moving the "current" data dir completely out of the way? – Isaac Bennetch Apr 13 '20 at 02:42