Solved

How to backup mysql databases

Posted on 2014-12-24
9
247 Views
Last Modified: 2014-12-24
My MySQL is currently installed in C:\xampp\mysql.

I tried backing up just C:\xampp\mysql\data, which is where all the database data is contained. But when I copied that directory to a new installation of MySQL on another computer, it couldn't see the databases at all. I had to create the database names, and then restore a mysqldump file for everything to be match the state of the original installation.

I am looking for a one-step restoration process that would make any MySQL installation match the state of the original installation. Can anyone help me do this?

Thanks.
0
Comment
Question by:elepil
  • 4
  • 4
9 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
Comment Utility
At the same level as the data folder there is also ib_logfile and ibdata1 files - you need them as they store the data and other things

Otherwise do an sql dump of your databases which is the better way
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 250 total points
Comment Utility
If you're migrating between the same versions of MySQL, copying the data folder should be enough.
Just be careful that both servers are NOT running when you do the copy/paste.

HTH,
Dan
0
 

Author Comment

by:elepil
Comment Utility
You know, I just found out why my copying the data folder over didn't work.

I have MySQL installed at C:\xampp\mysql on the source computer, and the databases are stored in C:\xampp\mysql\data.

However, the second PC I was copying the data folder to had MySQL installed at D:\xampp\mysql, and I had copied the 'data' folder to D:\xampp\mysql. It didn't work.

I just found out that the second PC, even though MySQL is installed at D:\xampp\mysql, it had stored its database data at C:\Program Data\MySQL Server 5.1\data !??. I don't remember configuring it to save the database data in that directory, so I don't know why it did that. Anyway, when I copied my 'data' directory to that folder, I couldn't open the databases, I was getting an error message that it can't read the .frm file.

This frustrates me to find out MySQL had stored its data in the C: drive even though I installed it at the D: drive on the second PC. And secondly, it seems simply copying the data folder over doesn't work.

Any advice?
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Thats the default install path for XAMPP
Leave the files in the D: path and just edit your mysql.ini file
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:elepil
Comment Utility
Gary, I have no mysql.ini. I do have a my.ini, and there is an entry in there called:

datadir = "D:/xampp/mysql/data"

So it is already pointing to where I thought it should be. I still see no explanation why MySQL stored all the data in the C drive.
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Yep thats what I meant.
XAMPP will by default install the MySQL data folder to the C: drive

Are you sure you are looking at the right my.ini?
0
 

Author Comment

by:elepil
Comment Utility
Well, I did a search in d:\xampp\mysql for *.ini, and the only other one that came up is a my-default.ini. But inside it, everything is commented with a #; besides, the datadir key didn't have a value anyway.

So my.ini is the only active .ini I could find, and it does say to store the database in the D drive, yet it stored it in the C drive.
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
You should be searching in c:\xampp\mysql or rather using the my.ini in that directory unless you have some funky setup going on .
0
 

Author Closing Comment

by:elepil
Comment Utility
I did a search in C:\xampp\mysql just like I said. I only saw the two .ini files I mentioned. The my-default.ini even explicitly stated in the comments not to modify it because it is used as a template.

I am left scratching my head as to why my MySQL stored its data in the C: drive, despite the datadir explicitly stating "D:/xampp/mysql/data". There is no other .ini file, that I am sure of unless it's located somewhere else outside of my D: drive.

This will have to go unresolved, but I thank you all for responding. I'm not wasting any more time on this.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now