Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I move my MySQL datafiles from one file system to another? 1

Status
Not open for further replies.

SantaMufasa

Technical User
Jul 17, 2003
12,588
US
My Unix admin requested that I move my existing MySQL data files (of all varieties...INNODB's and any others) from their current locations to another file system on the same machine. How do I do this in MySQL?

[In Oracle, we would:

1) shut down the database instance
2) physically mv the data files from their current location to the target location.
3) startup the database (but not open the database, just "mount" it, which means that Oracle has opened the database control files [that contain file-location names])
4) issue an:
Code:
ALTER DATABASE RENAME
    'old_file-1','old_file-2',...'old_file-n'
    TO
    'new_file-1','new_file-2',...'new_file-n';

ALTER DATABASE OPEN;
So, does anyone know the functionally similar commands for MySQL?]



[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Just shut down the server, move the files, and change the "datadir" entry in my.cnf to point to the new location. If your files are currently in the default location (probably /var/lib/mysql), then you might not have a "datadir" entry. If that is the case, then create one in the [mysqld] section. Then restart the server.
 
Woo-hoo, Tony !!! You Da Man (presuming that "Tony" is not short for "Antonia" [smile]). This all may have been easy for you to disclose, but I had no clue. You saved my bacon on a very tight schedule.

I wish that I could offer you more than just a Purple Star, but here it is, with gratitude.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top