...

View Full Version : Where are my databases!?



martynball
09-23-2011, 06:09 PM
Hey, this isn't exactly coding related but server. I basically need to backup a database as I need to restore my PC to factory settings. Apparently my databases should be stored in mysql\data.

This folder for me is here: C:\xampp\mysql\data

Although, for some reason the mysql cmd displays all of my databases, but some which are listed are not in the folder :S They are not hidden either. The "test" database was created using the CMD although the database I need to backup is "minecraft", but that is not shown in the folder...

Any idea where it is?
http://i.imgur.com/CS1TI.jpg

oracleguy
09-23-2011, 06:27 PM
Instead of just backing up the files you can/should use the mysqldump program that is in the bin folder under MySQL which is designed to backup one or all of the databases on the MySQL server.

But to answer your question as to where the files are, if some of those DBs are using the InnoDB storage engine they the data is all stored in the ib* files you see in that directory. If memory serves just copying those files to a new installation doesn't work, at least not without effort.

martynball
09-23-2011, 06:31 PM
I tried opening the mysqldump but it just closes. I have also tried the command that I have seen on some websites and that also doesn't work

oracleguy
09-23-2011, 07:50 PM
It is a command line application so you need to run it from an already open command window.

So:
Start > Run > cmd
cd \xampp\mysql\bin
mysqldump

Old Pedant
09-23-2011, 08:51 PM
Ummm...and you need to direct the output of the dump to a file.

And you need the username and password and databasename.

So:



c:\some\folder> mysqldump -uUSER -pPASSWORD DATABASENAME > databaseName.sql

There are other options available. When in doubt, you know, you can read the manual:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

martynball
09-24-2011, 05:23 AM
Okay, an error occured.



C:\Users\Martyn Ball>cd \xampp\mysql\bin

C:\xampp\mysql\bin>mysqldump -martynball -password minecraft > minecraft.sql

mysqldump: unknown option '-m'

C:\xampp\mysql\bin>


Is the last option (minecraft.sql) the name of the file which is to be created? Or where it is saved?

oracleguy
09-24-2011, 05:39 AM
You forgot the -u and -p in front of your username and password respectively. minecraft.sql will be the file where the database is backed up to.

You can run mysqldump -h to see all the different arguments you can pass the program.

martynball
09-24-2011, 06:01 AM
oooh, didnt realise i needed that :P haha. It has worked now thanks, how do I restore this after and merge it or add it back to mysql?

Old Pedant
09-24-2011, 06:13 AM
You'll love this:


C:\xampp\mysql\bin>mysqldump -umartynball -pPassword < minecraft.sql


In other words, you just send the SQL commnands that are in the ".sql" file to MYSQL and presto.

Caution: Don't do this if the database you are trying to restore still exists!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum