MySQL Tables Could Not Be Read - mysql

I'm using Appserv for local MySQL hosting. I had to reset my computer. I forgot to make backup for MySQL database and used Win 10 reset feature. So it removed all the applications but not personal files. After resetting my pc, I set up the Appserv again. I got into phpMyAdmin. On the left side, I can see all of the tables. But when i click on them, I'm having an error message "#1146 - Table 'database.table' doesn't exist". So i only have the MySQL data files which has database's .frm and .ibd files.
My question is, can i recover tables with these .frm and .ibd files?
Note: ib_logfile and ibdata files are overwrited after setup.

A quick search on Google I found an article that may help you but bear that in mind that once you erase something permanently by mistake or otherwise and if you haven't made the appropriate backups then I am sorry to say that whatever you do to try and resurrect it won't work.
Nevertheless, try out the link below and let me know of your progress:
http://www.voxteneo.com/restoring-tables-mysql-database-frm-ibd-files-available/

Related

Recovering a XAMPP database with ibdata1, .frm and .ibd files

Thanks for looking!
I've tried pretty much every solution I found online, yet nothing recovered a full database.
My client had a crash of MySQL on her XAMPP, and sent over the mysql/data folder along with WP root directory(it's a WordPress website).
-she erased the mysql/backup folder
-I've tried copying ibdata1, .frm and .ibd files into fresh XAMPP, but then I get the "Table doesn't exist in engine" error in PHPMyAdmin
Also tried SysInfo MySQL Database Recovery tool, which extracts the database when pointed to database folder, and without loading ibdata1. If I load ibdata1, tables are empty. If I point the software to the database directory, I get a full database, but with a few weird issues. Some are in wp_posts table(,, instead of ,'',) which brakes the element count, but I hopefully patched it. However, some other things are not showing well, all IDs are like "-9223372036854775555", and slugs have weird characters, like "a-lepsi-jutri��u癮u�".
Post statuses look messed up as well(like "itclosedclosedsta").
On WP side, this manifests as a 404 homepage error. You can access wp-login.php, but after entering the details and trying to login you get redirected to the homepage 404.
When I replace the entire mysql folder in fresh XAMPP with a backup from my client, MySQL won't start.
Have also tried starting it with repair level 1-6, but MySQL still won't start.
Have tried creating a fresh database, adding tables and fields with .frm files, discarding TABLESPACE then copying over only .ibd files and importing TABLESPACE. This works only for empty tables.
Also some other things, but nothing worked so far.
Any WP or DB thoughts - please let me know :)

Restore SQL database from backup of "C:\xampp\mysql\data" folder

Recently my laptop crashed and while making a backup of the XAMPP instead of taking a backup of the entire XAMPP folder I just copied the
"C:\xampp\mysql\data"
folder.
Now I am trying to restore the old database, the issue is if I try to just paste the folder of the database (Eg database folder named 'X123' - it cotains both ibd and frm files), then X123 shows up in PHPMyadmin but doesn't work as when I click on the table it says 'table doesnt exist'. I read other answers which suggested that I also replace the following files
ibdata1, ib_logfile1, ib_logfile0
When I try to do the same, MySQL simply stops working.
I have tried fixing the errors after reading some of the related answers here by importing the create_tables.sql file from "C:\xampp\phpMyAdmin\examples" and some other stuff but nothing seems to work.
I would really appreciate if you can guide me as to what would be the best way to restore this data on Windows 10.
I was able to find the solution on another answer at stackoverflow. Apologies for double post.
https://stackoverflow.com/a/46970116/9879647
In my case I also had to edit php.ini so as to increase the max execution time as well as file size that can be imported.

Xampp Mysql and Apache not Working - How to backup database

I'm having trouble with my Mysql and Apache server here for a week already. Tried to look for every possible solutions in the internet like changing ports and everything. Still no luck. I would like to reinstall Xampp, the problem is, I have important databases which do not have any backups yet. Is there a way to backup these databases without having my apache and mysql started?
It depends a bit on the type of storage engines you're using.
MyIsam
MyISAM tables are stored as files, so it is easy to do a backup by copying files (*.frm, *.MYD, and *.MYI files). In a typical XAMPP installation they can be found under c:/your/path/to/xampp/mysql/data/ .
InnoDB
Have a look at the manual:
Copy all InnoDB data files (ibdata files and .ibd files) into a safe place.
Copy all the .frm files for InnoDB tables to a safe place.
Copy all InnoDB log files (ib_logfile files) to a safe place.
Copy your my.cnf configuration file or files to a safe place.
However, if you have important databases, it is advised to think about a backup strategy before problems occur. MySQL offers a variety of backup strategies from which you can choose the methods that best suit the requirements for your installation.
Yes, you can just copy the data files. for innodb you need the ibdata1 (or similar) file. For MyISAM you will see 3 files (different extensions) for each database and the filename match the database names. If it is MyISAM then you can just copy these files back into the data directory on your new install and it will just work.
The other thing you should do is not use WAMP! It is easy enough to set up from scratch and much easier to figure out when things don't work.... you just need to read a little bit.
Copy all the files in your htdocs to another location first, duplicate the database organizers from information envelope and erase xampp then re-install it. You also need to delete the ib_logfile0, ib_logfile1 files from the data folder inside mysql folder.
Read here for further procedure https://dba.stackexchange.com/questions/3437/lost-tables-in-drupal-site-database

Restore MediaWiki site from physical files (MySQL)

One of our servers crashed last week and it wouldn't boot. So I got a full copy of the whole file system, and restored a previous backup. Now it is up and running, but there is a problem: the most recent changes made to a MediaWiki site were lost (the backup is a month old). It's not much, just a couple of modifications to some articles here and there.
I am currently trying to restore the last MySQL tables of the site. The proper way of doing that is with the mysqldump command, but this is not an option because I can't boot the server, I only have the files. So I read that you can do it manually if you copy all files in /var/lib/mysql/[dbname]:
How to recover MySQL database from .myd, .myi, .frm files
Restoring MySQL database from physical files
etc
Well, I tried stopping the MySQL service and moving the files from the copy to the server, and I even granted the database user privileges again just in case, but it won't work. The site keeps showing the month old articles (yes, I have cleared the cache, and rebooted) and I don't understand why, because the files I am restoring clearly have their "last updated" field set to the date when the last changes to the wiki were made (I know that for sure).
Am I missing something here?
Problem solved thanks to user #che. I had to copy the whole /var/lib/mysql directory, not just /var/lib/mysql/[dbname]. Apparently some database information is also contained in those files.

Can i restore some mysql database by just copying folder in Mysql

I have seen that i have folders corresponding to the databases i have in
/var/lib/mysql/php_site1
Now i want to know that i copy that folder and just paste inside other mysql, will it work or i need to do anything else as well
provided i have same setting
It depends, I assume that you use InnoDB tables, when you shutdown your mysql instance you can backup the files, make sure it includes the following:
ibdata and *.ibd files
*.frm files
ib_log files
my.cnf files
On the new machine make sure you make the adjustments in the my.cnf which suits your database layout. If you are not absolutely sure what you are doing, i would suggest to use a simple dump to archive your goal. I have seen many times where people tried to copy the database and where left with a useless db.
Also please read this part of the documentation carefully: MySQL Docs