MySQL > Administration > Commands > Manually Replacing a Broken Database.
| Databases |
It may occur that one or more of your MySQL 4.x or 5.x databases gets messed up, corrupt, broken, or otherwise unusable.
Should that occur, there is a quick way to replace the bad version with a working copy. (Of course you DO backup your databases, right?)
So here's the way to do that, in just 7 steps. (Yes, really).
# HOW TO replace a non-working MySQL 4.x or 5.x db with a working copy in 7 Easy Steps:
1) Stop mysql.
2) Open the database archive (you may have it in tar or some other compressed format). For the purpose of this example, tar is the compression format.
3) Run:
cp the mysqlbackup.tgz file to /var/lib/tar/
4) Then inside that dir expand it by running:
tar zxvf mysqlbackup.tgz
5) Then run:
rm -rf my_data_base/*
Note: Don't be a dolt: Obviously, insert your database's name in place of "my_data_base".
6) Then run:
mv tar/mysql/my_data_base/* /var/lib/mysql/my_data_base/
Note: ibid.
7) Finally, restart mysql.
Note: That's it! Your bad copy should be gone and your working copy should be running in MySQL. Pass it on.
# # # # # BACKUPS OF YOUR DATA ARE A GOOD THING # # # # #
more digital solutions found at:
MySQL.org
xdose.com
ContentAndAds.com
qmailrocks.org
FreeBSDRocks.net
TheSwamp.info
FileCorner.com
Should that occur, there is a quick way to replace the bad version with a working copy. (Of course you DO backup your databases, right?)
So here's the way to do that, in just 7 steps. (Yes, really).
# HOW TO replace a non-working MySQL 4.x or 5.x db with a working copy in 7 Easy Steps:
1) Stop mysql.
2) Open the database archive (you may have it in tar or some other compressed format). For the purpose of this example, tar is the compression format.
3) Run:
cp the mysqlbackup.tgz file to /var/lib/tar/
4) Then inside that dir expand it by running:
tar zxvf mysqlbackup.tgz
5) Then run:
rm -rf my_data_base/*
Note: Don't be a dolt: Obviously, insert your database's name in place of "my_data_base".
6) Then run:
mv tar/mysql/my_data_base/* /var/lib/mysql/my_data_base/
Note: ibid.
7) Finally, restart mysql.
Note: That's it! Your bad copy should be gone and your working copy should be running in MySQL. Pass it on.
# # # # # BACKUPS OF YOUR DATA ARE A GOOD THING # # # # #
more digital solutions found at:
MySQL.org
xdose.com
ContentAndAds.com
qmailrocks.org
FreeBSDRocks.net
TheSwamp.info
FileCorner.com


