Help - Search - Members - Calendar
Full Version: How to restore mysql databases from /var/lib/mysql/user_database/ files only?
The Planet Forums > Control Panels > cPanel/WHM
bjdea1
Hi,
as the title asks. I recently had a harddrive failure and luckliy I can still access certain directories on this failed drive. I can still access the /var/lib/mysql/ directory which holds all the users databases and have backed all these up separately using tar.

Now what I need to know is how do you restore these database files to another server? I tried simply untar'ing one of these to the new servers /var/lib/mysql/ direcotry and it stuffed Mysql up - it went offline. I had to get a cpanel tech to bring Mysql back online.

So how can I get these database files to fully work on a new server? Please any help would be greatly appreciated.
James Jhurani
cPanel now stores some things in the MySQL database. As long as you new drive has the same or similar versions of software, you should be ok copying the entire MySQL database over from the old drive to the new one. You would need the database named mysql as all the users and password hashes are stored in it.

if that doesn't work, you can do one of two things.
1. change the data directory in your mysql configuration, and start the daemon running from the old data dir. Then export your databases using mysqldump, restart the daemon with the new data dir location, and import the databases.

2. mount the old directory using "mount --bind /path/to/old/var/lib/mysql /var/lib/mysql". That should bind the old directory on top of the new one(dont worry the old content is just hidden since something is mounted on top of it). Then restart mysql, and dump your databases. Once you finish that, unmount the aforementioned mount point and restart mysql... then import the databases.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.