Import MySQL tables recovered into new MySQL Database - mysql

I have the data files of an old MySQL database (.frm, .MID, .MYI), taken from a server hard disk.
No way to be sure about MySQL version: I have no access to the server, I only know the server was a linux machine, built in 2009 or 2010, and then left alone without maintenance.
I downloaded and installed the last MySQL .MSI, but I'm totally new to MySQ.
The first step I need is importing my data into a new MySQL database, and then with a Delphi program I plan to move the data into a SQL Server DB.
How can i import these data tables?

Yo can stop mysql server, create some folder like old_data in mysql data directory, put all your .frm, .MID, .MYI files there and start mysql. After doing so you should be able to see old_data database in results of the SHOW DATABASES command.

Related

Restore SQL database for WordPress

Unfortunately my VPS got corrupted and therefore I wasn't able to perform an export of the sql database with phpmyadmin. I do managed to copy all the SQL files .frm, .idb, .opt etc
Is it possible to recover the database and make my wordpress site working again?
Im using centos7 with Plesk Onyx / phpmyadmin
Absolutely! First get a new instance of your VPS running and create your database again, after created copy the .idb(innodb) or .myi/.myd(mysami) files right back where you found them
Each table comes with a .frm, don't forget those, as well as a db.opt for the database
Typical mysql storage (on linux) is located:
/var/lib/mysql/database_name
Once copied over restart mysql and check again

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.

Import .bak to MySQL (.sql)

I want to import a MS SQL SERVER2008 R2 database backup to MySQL Server. Any help on how I can convert the .bak to a .sql so that it can be imported to a MySQL database server?
I have read other threads regarding this but none have worked so far.
Thank you.
You can restore the database to a local version of SQL Server (you can download the free evaluation edition to do this):
http://msdn.microsoft.com/en-us/evalcenter/ff459612.aspx
Then you can use the import/export wizard in Management Studio to transfer your tables and other objects to your MySQL database (you may need additional ODBC drivers installed locally in order for SQL Server to establish a connection to MySQL).
EDIT
When restoring the database to SQL Server, don't use the clunky UI. Use an actual RESTORE DATABASE command. For example:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak';
Now, you may find that the original database was created with files placed on drives or folders that don't exist locally. So I suggest creating a very simple folder, temporarily, called c:\db_temp\, giving the Everyone account modify privileges, and then running the following:
RESTORE FILELISTONLY FROM DISK = 'c:\path\foo.bak';
This will return a resultset like:
LogicalName PhysicalName
----------- ------------
Foo C:\...\foo.mdf
Foo_log C:\...\foo_log.ldf
You need to build a RESTORE DATABASE command something like the following, based on the result above:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak'
WITH MOVE 'Foo' TO 'c:\db_temp\foo.mdf',
MOVE 'Foo_log' TO 'c:\db_temp\foo_log.ldf';

How to recover Mysql database from backup files

I have using VPS that had to be re-imaged. my DB was part of it and it was being backup up as the app wasn't in production yet. However, there is some data that I wish to recover on it. the VPS provider is giving me a backup of the image (Ubunto Linux) that has all the files.
Is there a way I can recover my data?
The mysql data files in Ubuntu are located at /var/lib/mysql
To restore your database you need:
1) create new database named as old one
2) stop mysql server
3) copy old database files from /var/lib/mysql/your_database_name/ to new system
4) start mysql server
Your database will be restored.

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.