I have all data in MySQL's .frm files. How can I restore the data? I do not want to restore all of them, just some records and tables so I need to make dumps out of them.
From what I can see, there are only .frm files, no .myd files. There is, however, ibdata1 file. How am I supposed to restore?
I got it working.
1) I created an empty database named after what the real database was on the server in my local installation.
2) I killed "mysqld"
3) I copied the three ib* files to my local MySQL data directory (on Windows it was a hidden folder in root drive). Make sure you copied to InnoDB data file directory, depending on your my.cnf InnoDB and MyISAM data may be stored in different folders. I also copied the .frm files.
4) I ran "C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file="C:\Program Files (x86)\MySQL\MySQL Server 5.1\my.ini" --innodb-force-recovery=6
5) I ran mysql -uroot -pmypass to confirm use mydb; select * from mytable; returned results.
6) I used mysqldump mydb mytable --compact > file.sql
That's it!
Very Simple Steps.
In Xampp Control Panel Click on config of MySql then select "my.ini" file.
In this file add a line innodb_file_per_table=1 after [mysqld] line.
Now, I created a same database which you want to recovery like name as exam_table
Create one by one table which you want to restore like name as exam_time.
Run SQL query/queries ALTER TABLE `exam_time` DISCARD TABLESPACE;
Caution: This deletes the current .ibd file.
Copy the backup exam_time.frm & exam_time.ibd file to the appropriate database directory.
Run SQL query/queries ALTER TABLE tbl_name IMPORT TABLESPACE;
Check Your exam_time table its recovered .....Hurrahhh
Related
My system was crashed. I try to import my database from .frm files.
I copied those files to my new mysql server location . '/var/lib/mysql'.
I gave the change the priviledge. I had one database.
I just compied the following files to my database foloder name 'my_school'.
ibdata1
ib_logfile0
ib_logfile1
I copied the whole folder to mysql folder location in ubuntu 14.04, /var/lib/mysql
I gave the privileges to this folder using this command.
chown mysql:mysql /var/lib/mysql/my_school -R
Then, I try to access the database. I can access the database. I can see the tables. but, it give error when I try to see the table structure or data.
the error it show this is.
ERROR 1146 (42S02): Table doesn't exist but both table files (frm, ibd) exists on the file system
I used these solutions, these solution doesn't work.
MySQL > Table doesn't exist. But it does (or it should)
MySQL > Table doesn't exist. But it does (or it should)
Please, help.
Is .frm file contain both data and structure of the data ?
what is purpose of ibdata1 file?
what is purpose of ibd_logfile0 and ibd_logfile1 ?
When i just write "mysql" in bash - it show only 2 databases.
When i write mysql -u root -p and then enter password - 2 more db occur.
Why is it happening?
+ bonus question: i backed up "data" directory from previous mysql installation, which crashed.
How to restore tables from .ibd and .frm files?
mac os 10.9
Why is it happening?
As documented under SHOW DATABASES Syntax:
You see only those databases for which you have some kind of privilege, unless you have the global SHOW DATABASES privilege.
Presumably the account under which you connect to MySQL when no explicit credentials are provided (i.e. as set in the relevant option file) only has permission to see two of your databases.
How to restore tables from .ibd and .frm files?
See Copying Tablespaces to Another Server (Transportable Tablespaces). If the files are in the server's data directory, you can use IMPORT TABLESPACE:
ALTER TABLE tablename IMPORT TABLESPACE
I setup fresh xampp(latest version) and copy mysql/data folder from old xampp(little bit lower version).
When I am access my magento project database through phpmyadmin, i am shocked. Here only 19 tables listed.
I checked in mysql/data directory, database folder and files with tables name(*.frm) are exist.
Please let me know how can i get back my complete database?
PS: I am using window 7.
In Magento most of the tables are innodb (except for those 19 you found in your new installation). For innodb tables you cannot just copy the table files from the data folder. See this for more explanations.
If you cannot create a dump of the old db and restore it in your new xampp it may be lost.
When copying Magento Database, be sure to use "Single Transactions". Otherwise, it will cause issues.
this is how I do it using command line:
Dump existing table into a file:
mysqldump -u [YOUR USER] -p'[YOUR PASS]' --single-transaction --database [Your DB Name] > [FILE-NAME-TO-DUMP.sql]
Then copy the file to the server you want to create the database.
Create your database that you'll be using on the new server
Run the following
cat [FILE-NAME-TO-DUMP.sql] | grep -vi "^USE" | grep -vi "^CREATE DATABASE" | mysql -u [YOUR USER] -p'[YOUR PASS]' --database [Your DB Name]
Trying to find out how people do a full backup/restore procedure: The user defined database schema and data can be easily backed up via mysqldump, but what about the master tables and data? i.e. if the server goes completely bananas, how can I rebuild the database, i.e. including all the settings in Mysql? is it just a matter of dumping/importing the information_schema and mysql databases + restore my.cnf ? (innodb or MyISAM, not ISAM)
--
edit: Thanks!
You don't back up information_schema, but otherwise, yes, keep a copy of your my.cnf and a dump of the mysql db tables and log settings. To do this do:
mysqldump -u$user -p$pass --all-databases > db_backup.sql
If you're going to restore to the 100% same version of MySQL, you could also backup by shutting down your server and doing a full copy of the contents of /var/lib/mysql (or wherever your data files are) along with your my.cnf file. Then just drop the copy back in place when you want to go live and turn on your server.
I know, it is really sad trying to export a database just by copying the data folder! But I have a hard disk with an important database inside and I don't know how to export this database onto my actual system (winxp - mysql 5.0.37).
So, i've copied old_harddisk/program/mysql/data/coge2010 to mypc/programs/mysql/data/coge2010
Result:
I see cogemilla (4) on my phpMyAdmin databases summary (it's correct!!! my 4 tables!)
If I click the database, I see just 1 table (oh no!)
On the mysql error log file I find messages like this one: "...[ERROR] Cannot find table coge2010/soci from the internal data dictionary of InnoDB though the .frm file for the table exists. Maybe you have deleted and recreated InnoDB data files but have forgotten to delete the corresponding .frm files of InnoDB tables, or you have moved .frm files to another database? See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html how you can resolve the problem."
Any ideas?
You should create a dump and import it on the new server.
In Command Prompt type the following to create the dumpfile:
mysqldump -h host -u user -p databaseName > dumpFile.sql
To import the database :
mysql -h host -u user -p databaseName < dumpFile.sql
You can only copy InnoDB tables if:
1. Your database is stopped.
2. You copy all InnoDB files (ibdata* ib_logfile* /*.ibd
You could use dump/restore to copy a single table.
You could user 'ALTER TABLE sometable ENGINE=MyISAM' to convert it to MyISAM and then copy the MYI,MYD and FRM.
Percona XtraBackup can do single table restores if you're using Percona Server.
This post may help you.
Another post which may help you.
A mysql table is defined by 3 files (FRM/MYD/MYI). In your case the FRM file is missing into the database folder.
If you can run the mysql server of the old hard disk it is easier to do a dump of your database. The following link shows you how to do this