Link to home
Start Free TrialLog in
Avatar of designersx
designersx

asked on

Where the mysql tables are stored in windows if i want to get their backup?

i have two hard disks. now i want to get/export/ import all the tables of mysql of previous hard disk and use them in freshly installed mysql in new windows.
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Is the mysql server running for the old data? Or do you have the old database on a "slave" disk only, not connected to a running mysql server?
If you have a running mysql server for the old data, you can use phpMyAdmin or mysqldump utility to create a dump file.

http://www.phpmyadmin.net/
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
To import the files into the new server, use phpMyAdmin or from the windows command line (Run -> cmd):

mysql -uroot -p database < database_dump.sql

You may need to cd to your mysql directory first, if not the mysql/bin directory is in your path.
Avatar of designersx
designersx

ASKER

i have installed mysql server on my new windows.

my previous database tables are now in    d:\wamp\bin\mysql\mysql5.0.51b\data  so i which path i should go exaactly, please tell me

yogesh
designersx, want cxr is saying, is that even if you point it to the correct directory you will not get a good backup.  If mysql is running, you cannot back the files up because they will be locked.  You need to create backups of those files through the dump utilities and back up those dump files.
LinuxNubb: i didn't get u?
You cannot back up open files.  If you try to back up the open mysql database files, you will get errors.

If you create copies of the database files as cxr describes above, you will get good backups.  You can create those files anywhere you like and can back them up correctly and successfully.
In the data folder you will find one folder for each database. Within the dabase folders are all myisam tables, but not innodb tables! If you have only used myisam tables, you can try to copy the database folder to the data folder of the new mysql server. The new server should recognize them immediately, no configuration needed.

The old version was 5.0.51b, which version has the new server?

If you have used innodb files, it becomes more difficult.
would u please explain this statement.

mysql -uroot -p database < database_dump.sql

what is database_dump.sql  ?
>> what is database_dump.sql  ?

That would be the name of the dump file created by phpMyAdmin or mysqldump. To be able to create a dump file, the database must be running.
my all database tables are kept safe  in this path    D:\wamp\bin\mysql\mysql5.0.51b\data    (this is the d:

of my new windows but actually it was the c: drive of other hard disk.)  now i want all of them into

C:\wamp\bin\mysql\mysql5.0.51b\data   how i should do , i am unable to run the above command

mysql -uroot -p database < database_dump.sql

what i am doing is :- in windows command line,

c:\wamp\bin\mysql\mysql -uroot -p database < database_dump.sql  

it is giving error, the system cannot find the file specified.
how do i come to know that i am using innodb tables or myisam tables?
Assuming the database server is not running for the old mysql, you can try to copy the old databases to the new mysql server. I don't know if you have many databases you wish to restore? Try it with one database first: below the old data folder, you will find a folder with the name of the database. Copy this folder to the data folder of the new mysql. This only works if all tables are myisam, because innodb tables are stored in a separate data storage file, and this is more complicated to copy to a new server. It might not work if the mysql versions are different. The old one was 5.0.51b, what version is the new install?
Same version, thats good. Lets hope it is not innodb. You can find that out by doing this from the command line:

dir D:\wamp\bin\mysql\mysql5.0.51b\data\OldDatabase

If there are three files for each table, *.frm, *.myd and *.myi files, then this is myisam tables. If you only have *.frm files, it is innodb, and the data is stored in a different file.

Reading data from the database_dump.sql dump file requires that you have such a dump file, and you don't.

To copy the database, do this from the windows command line:

copy D:\wamp\bin\mysql\mysql5.0.51b\data\OldDatabase C:\wamp\bin\mysql\mysql5.0.51b\data\NewDatabase

...where "OldDatabase" is the name of the old database and "NewDatabase" is the name you want to have for this database on the new server. If you use a name that allready exists on the new server, it will overwrite any existing tables in the new database server.
my versions are same.

it is showing only frm files and 1 opt file. i think it is innodb.
with this,

copy D:\wamp\bin\mysql\mysql5.0.51b\data\OldDatabase C:\wamp\bin\mysql\mysql5.0.51b\data\NewDatabase

1 file is copied but the complete folder is not shown that had 3 tables.
i think i have lost the tables.

this is really wrong. it should not be like this.


yogesh
ASKER CERTIFIED SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial