Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to backup mysql databases

Posted on 2014-12-24
9
Medium Priority
?
262 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 500 total points
ID: 40516886
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 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 500 total points
ID: 40516891
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
ID: 40517104
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 58

Expert Comment

by:Gary
ID: 40517109
Thats the default install path for XAMPP
Leave the files in the D: path and just edit your mysql.ini file
0
 

Author Comment

by:elepil
ID: 40517114
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
ID: 40517119
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
ID: 40517127
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
ID: 40517237
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
ID: 40517296
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month6 days, 10 hours left to enroll

783 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