0

I am using XAMPP 5.6.23-0 on a Mac.

I have experienced many problems with MySQL, where the server simply refuses to restart after something has happened (not sure which events make it crash). In the end, the only working solution was to re-install XAMPP. The problem is that the new installation does not automatically pick up the databases that were created in the old installation, even if they are in the same physical location on my disk.

The obvious restore method for a MySQL table or database is of course running the restore by importing an earlier SQL backup from phpMyAdmin, but you need to have that backup, and that is impossible to create after the MySQL server dies and refuses to restart. Running a backup after every single database change is not feasible and should not be required IMHO.

I have tried to completely remove the remaining xamppfiles folder before a reinstall of XAMPP, and that works, but of course the databases I have created are not available anymore. I dug out the files from a Time Machine backup, manually added them to the xamppfiles/var/mysql directory and changed permissions to match those of the databases included with the XAMPP package (chmod 770 on the custom database directories in xamppfiles/var/mysql).

Running phpMyAdmin shows that the custom databases and the tables are visible, but when I try to access any of them, there is an error that the table does not exist in the engine. I did add the user account in the new XAMPP installation that has the same name, password and privileges as used in the old installation, so it is not an issue with access privileges. Simply the message that the table does not exist in the engine.

There must be some file(s) in the XAMPP installation that the MySQL server uses to find the various databases and tables. If anyone can point me to that file I can probably dig it out of the Time Machine backup as well and try to make the new installation (same XAMPP version) run with that configuration file to regain access to my custom databases.

Any pointers are welcome. If this cannot be done, also please let me know so I can stop wasting my time on XAMPP and get a stable MySQL server installation instead.

migrated from stackoverflow.com Oct 22 '17 at 15:25

This question came from our site for professional and enthusiast programmers.

0

Your best solution is going to be to install MySQL, stop the service, then completely replace the entire "datadir" with the one from the backup, then cross your fingers before restarting the MySQL service.

The datadir is probably the folder you found in xamppfiles/var/mysql; that sounds right but I don't use XAMPP to know for sure. You can open up the command line client and issue the command SHOW VARIABLES LIKE "%datadir%"; to confirm the proper path.

You can't simply restore the parts of what are missing alongside the existing structure, because you also need the information about which users have access to the tables and other metadata that isn't stored directly in the individual database folder. Restore the entire folder so you get all the correct metadata, database and table structure and data, and permissions.

This is a bit beyond the scope of what MySQL is meant to do, so success is not guaranteed (proper backups usually involve making a .sql file export, which you can do from phpMyAdmin or the command line; I use the 'mysqldump' command line client).

  • Thanks, I will try this as soon as I find the time. I will let you know if it has worked out. The problem with backups is that you need to make them before a system has crashed, and I have not found a pattern in the crashes yet. Is there an automated backup service that I can configure for XAMPP? – 4everJang Oct 23 '17 at 19:21
  • I use a launchd scheduled job (since cron has been deprecated since 10.4, but secretly I still use cron on my Mac). My cron job simply calls mysqldump with a few command line options to dump specific databases and put the output in a particular folder. There are plenty of publicly available tools that do something similar; I know of sourceforge.net/projects/automysqlbackup but haven't used it in ages so can't comment much on it. – ibennetch Oct 23 '17 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.