MYSql 5.5 Upgrade Issue: All tables gone - mysql

I had MySql 5.1.13 Database on Windows 2008, then on one fine day I took backup of my server [300+ databases]. Uninstall Old version and install 5.5 Version of MYSql. Now I copy the Data Folder back in Mysql 5.5 data location and I got all my Databases, but later I realise that around 250 Databases though did present at location but they do not show Tables in PHPmyadmin. I try to run "Show Tables" on couple of those database and Tables name does shows [and so as tablename.frm files exits] .
not to mention all tables that are Innodb are only one missing. How can get them back with ease. I have backup of each database but running 250 SQL files is not easy :).

Your innodb engines can have their own seperate folder where they store their data files. According the MySQL manual InnoDB creates tablespace files in the MySQL data directory by default see: http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html.
Normally you would split you tables onto different drives to increase performance thus you might have a scenario where the InnoDB tables where configured to be placed on a another drive or folder. If you have it please check the previous MySQL configuration file and check for the following line: innodb_data_home_dir = /ibdata
This will indicate where the files are located. I have not tried this but you should be able to point the current config to the old innodb location if this is the case. If that does not work I think restoring will be you best bet.
Good luck!

Related

Read MYD, MYI, FRM files

I've read several posts on this forum and others and still can't read some MYD/MYI/FRM files which contain data that I want to import into SQL Server.
I stopped the MySQL service at the client location and copied all the files (the same way that we would do with SQL Server).
I have installed the most recent MySQL ODBC connector, MySQL engine and MySQL Workbench on my Windows 10 PC. The engine is running and the ODBC connector is configured with a username and password. Using the workbench, I have been able to successfully log in.
I created a MyTest database which created a C:\ProgramData\MySQL\MySQL Server 8.0\Data\mytest folder.
I stopped the MySQL service and copied MyData.MYD, MyData.MYI and MyData.FRM to the mytest folder.
I restarted the MySQL service.
But if I run a "Select * from mytest.MyData" query in the workbench or using the MySQL 8.0 Command Line Client, it keeps indicating that the table mytest.MyData doesn't exist. Now, I read that it might be appropriate to run a CHOWN command but I don't know what if syntax would be different for a Windows system and whether this command would be executed directly from a Command prompt.
Any assistance would be greatly appreciated. Thanks!
Older versions of MySQL let you get away with that for MyISAM tables, but MySQL 8.0 introduced a whole new implementation of "data dictionary" which is a meta-database maintained internally, and it has a bias for InnoDB over MyISAM. So I would believe that moving files around ad hoc no longer works as it once did. To move tables from one instance to another, you should really do the export and import steps properly.
For InnoDB, you may use transportable tablespaces. At least you don't have to do a full data import that way, but it takes a few more steps than just file copy.
P.S.: I haven't used MyISAM in many years anyway. I prefer my database to support ACID properties, and MyISAM does not support any of the ACID properties.

Are ibdata1, ib_logfile0, ib_logfile1files required when migrating MySQL to another new server?

I am migrating MySQL from an existing server running MySQL 5.0 to a new server running 5.6. The source database is using MyISAM and INNODB engine. It has innodb_file_per_table parameter enabled.
I have copied all the user database data files from source server to the destination server. MySQL and Performance schema database is not copied.
I am not sure if I should copy ibdata1, ib_logile0, ib_logfile1 over or I should just use the default ones that already created in the destination server when I first installed MySQL 5.6?
I have to result to copying instead of binary dump using mysqldump and restore the database is huge at 4TB. I do not have a long downtime for the source DB and mysqldump will lock the tables for longer than a copying.
You are contemplating an advanced operation, which requires considerable expertise, because it is in fact an upgrade directly from 5.0 to 5.6, which might work, but is not supported.
The recommended path is to upgrade through each major release, 5.0 to 5.1 to 5.5 to 5.6.
https://dev.mysql.com/doc/refman/5.6/en/upgrading.html
Yes, you need the system tablespace (ibdata1) and to avoid getting your server into an inconsistent state, you also should retain the ib_log* files as well as a my.cnf with settings compatible with those log files.
Dumping and reloading is a better (safer) approach than a binary (file copy) migration, but even then you may need to handle the "mysql" schema manually, due to structural changes across versions. Loading a 5.0 dump directly onto a 5.6 server might work, if you immediately run mysql_upgrade after loading the dump file, to bring the system tables up to date, since loading the 5.0 dump onto a new server will mangle them.
Proceed with caution.
You may clean ib_logile0, ib_logfile1 but not ibdata1. ibdata1 file contains the innodb data where as ib_logile* contains the logs.
Also check the MySql documentation whether coping data files between major releases are advisable? I think it is better if you can get a dump and restore because there are some structural differences. In this way you may get some data issues.

I Want to use a mysql database from a backup of a non-working server on a new computer

My database is from a backup of the non-working server.
My database is the teachercenter folder that was on the server, and contains files for each table name with the extension *.frm.
I copied the database from:
C:\Users\xxx\Downloads\wamp-saved\wamp\bin\mysql\mysql5.1.36\data\
And pasted that folder on my computer here:
C:\wamp\bin\mysql\mysql5.6.17\data
I realize the the two mysql's were different versions, but I'm just trying to use the database files.
When I start up PHPMyAdmin on the new computer, it shows the teachercenter database in the list of databases.
Also, if I click the plus next to the teachercenter database, I can see a list of my database tables!
But if I click on teachercenter database itself, I get error:
No tables found in database.
How do I get mysql to recognize and let me operate (PHPMyAdmin) on the teachercenter database on the new computer?
I tried to start/use wampmanager.exe, but I don't see it running to use it's menus.
THE PROBLEM IS SOLVED:
At: stackoverflow.com/questions/10934745/… a simple answer to my probelem is given, as follows: "Yes this is possible. It is not enough you just copy the .frm files to the to the database folder but you also need to copy the ib_logfiles and ibdata file into your data folder." I copied the ib_logfiles and ibdata file into my data folder, and Voila! PHPMyAdmin was completely happy with the database and its tables and I could do SQL exports of table records.
Summary: To make use of a MySQL database of *.frm files that your MySQL doesn't understand, simply copy the ib_logfiles and ibdata file from whereever you got the .frm files from, and put these two files in the data folder next to the database you want to use. Once you do that, the MySQL database engine will recognize your database, and you can all PHPMyAdmin operations on your fully operational database.
Because you can't be sure that the MyISAM storage format backwards compatible, your safest option is to install MySql 5.1.36, use mysqldump to export your entire database to plain SQL, install MySql 5.6.17 and then import your data using SQL.
Also, this probably gives better results because your indexes are rebuild.

How can I recover MySQL tables from data files?

I've got a database (all MyISAM tables) and the machine where MySQL was running is no longer bootable. However, we have all the MySQL data files from the data directory. How can I restore the data from the MYD and FRM files, or whatever other files I should be looking at in the data directory?
I've been doing some searching on this and it sounds like for MyISAM I should just be able to copy the database subdirectory from the old MySQL data directory to the new MySQL data directory. However, that's not working for me. A database with the name of the database I'm trying to recover shows up in the list of databases in phpMyAdmin, but all the tables show "in use" and have no information (e.g., number of rows, number of bytes, column information, etc.). Any operation on those tables (e.g., SELECT * FROM {table}, REPAIR {table}, CHECK {table}) returns a "no such table" error.
One of the tools I ran across in my search is DBACentral by MicroOLAP. It's got component that's supposed to restore data from FRM/MYD files, but when I tried to run it, it didn't list any tables that it could recover from my FRM/MYD files.
This is on a developer workstation that's running Vista Business 32bit. MySQL version is 5.0.27. After fixing the machine, I went and got the exact same version of MySQL (v5.0.27), thinking that if I'm just going to drop in the binary data files I should do it with the same version of MySQL. It still didn't work.
Any insights would be greatly appreciated... thanks!
-Josh
Install the same version of mysql.
Remove mysql directory from data directory of the server and copy it from the crashed server. This is the key element
copy directory of database you want to recover into data directory of new server
start mysql.
switch to mysql database: USE mysql; and run REPAIR TABLE <table name> on every table.
Do the same with database you want to recover
tip: make sure the 2 directories have the same permissions like data directory
If you did not save mysql database (mysql directory in your old server's data dir, then you can try to:
create database with the same name as database you want to recover.
Then you can create each table (it would be good to use the same structure - you'd have bigger chance of recovery).
then stop mysql server and delete files from database directory and overwrite them with files from old server
start mysql and repair each table.
I wound up giving up. I think the answer is that, with my particular version of MySQL, this doesn't work. Hopefully things have improved since then.

Restore mysql server from myd myi files - windows

I have a recovery disc image which contains the datafiles for mysql server.
The original server is unavailable - all I have is the datafiles (programdata, program files etc).
I am not able to make a mysqldump file.
On the new server, I've installed the exact copy of mysql server, and copied the files/folders (all the myd myi files) from the disc image to the new server.
After restarting the mysql service, I can see the list of my databases in mysql administrator.
However, when I try to view a table, I get an error:
"1146 The table {dbname}.{tablename} does not exist."
I tried running myisamchk but this says there is n problem (at least no error is displayed)
Can anyone help?
Bob
You will need a copy of the corresponding .frm files, which contain the format information MySQL needs to read the raw row data from .myd/.myi or ibdata files. Without the .frm files, MySQL does not know the tables are even supposed to exist (which is why they're not found, and myisamchk doesn't see any broken tables).
If you don't have these files, you may be in trouble. You should be able to reconstruct the .frm by re-CREATEing the tables from scratch, then stopping the server and dropping the .myd/.myis over the empty versions. But you will need to know the exact datatypes and indexes that were originally used in the schema. (“Very difficult repair”)