MySQL .frm/.myd/.myi - mysql

I have a MySQL database with test data. I have been modifying routines and triggers in this database. I have a new .tar file containing *.frm, *.myd, *.myi, *.trn, and *.trg files for this same database with production data. I want to take only the actual data from the tar file and move it into my existing database. May I simply move the *.myd and *.myi files from the tar file to the current folder for my database without corrupting the schema?

Yes, you should be able to do that just fine. frm, myd and myi are MyISAM tables and you can copy and moves those around without corrupting anything. Although, technically you should have the database shutdown when you do that. If that is not an option, make sure you run "flush tables" before copying anything.
Once you copy those into the mysql data directory, make sure the privileges are correct. Then you should be able to see them in mysql. As I said, you can do this while mysql is running, but I don't recommend it.
You cannot do this with Innodb tables (i.e. .ibd extension).

Related

Where are my .myd, .myi and .frm files from my mysql database

I'm a beginner here and I can't seem to find the files. My professor wants me to send these files specifically to her, but when I "export data" from the workbench, it only generates .sql files. Where do I get the .myd, .myi and .frm files she's looking for.
Thank you
Don't worry about those. That's just how MySQL stores the data internally. If you read the documentation carefully you'll soon learn that you shouldn't depend on those files for backups anyway, they're likely to be in an inconsistent state if the server's running.
The best way to make a backup for small to medium-sized databases is the mysqldump command. There's a number of options that can be applied but the most important on a busy database is --single-transaction which produces a consistent point-in-time snapshot.
The SQL data you get from that, which can be saved to a .sql file, is sufficient to recreate the database and is a backup.
You can restore with the mysql command-line tool, or if you're not comfortable with that, the MySQL Workbench program.
Somewhere there is a data directory under a directory with MySQL in the filename, and under data is your own database directory. Files are in there. But if you haven't used MyISAM as the table format, the files will have different extensions, e.g. .idb for InnoDB.
You can find it via the query mentioned in #tadman's comment, or from a shell:
find / -name data -print
although you will probably get a number of matches.
You will have to stop the MySQL server before you can copy the files.

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.

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

MySQL database disappear

I have done an idiot mistake, i cut the database folder in /var/lib/mysql folder and paste into my external hard drive because my hard disk was almost full.
Now i copy the database folder back into the original mysql folder, i cannot access the database anymore, phpmyadmin says it is an empty database.
Is there any way to recover the old database? If it disappear permanently it will be a big pain for me
What is the engine for your tables? InnoDB or MyISAM? If it is MyISAM then yes they can be recovered if you still have all the files but if type is InnoDB then there might be some trouble
And after pasting the files back to original directory you have to restart mysql server too.

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”)