I. Error Correction
After detecting the database of phpBB in MySQL, we found that there was a problem with the users table. We tried to repair it using myisamchk and found that the preset repair method was not available, add more "-o" parameters. When using myisamchk, it is best to stop the MySQL service to avoid users accessing the database, otherwise, at least the next "mysqladmin flush-tables" command will be executed, such:
Myisamchk-o phpbb2_users.MYI
This action may take 2 ~ 3 times until no error message appears!
After repair, after restarting the MySQL service, you can use the mysql client command to Query the database content and test whether it is normal. fortunately, the database works normally at this time.
Of course, before you back up the data, it would be better to check whether the data is correct first. If necessary, you can schedule the detection before the backup, but remember, this DB detection action should not be scheduled during the high DB usage period. It is a good choice for the time when no one goes online late at night!
Ii. Start backup
There are two main documents in the phpBB discussion board: the php main program and the DB content. The backup of the php main program is relatively simple. You just need to tar all the files, like:
Tar cvfz phpbb2_20020601.tgz phpbb (the above phpbb refers to the php webpage program storage directory of phpBB .)
After that, you can change to the phpBB web page and back up the file again. The content and materials of the php web page are all written in the database. Therefore, some changes to the php file should be minor.
In MySQL DB, the database file of the default MySQL database exists in/var/lib/mysql, and the database name is used as the directory. The directory contains all the data of the database, A database like phpbb2 exists in/var/lib/mysql/phpbb2. Before the backup, MySQL locks the database file in use because the data is not completely written to the disk, so we should first shut down MySQL, and the entire backup program can be completed as follows:
/Etc/rc. d/init. d/mysqld stop
Tar cvfz phpbb2_db_20020601.tgz phpbb2
/Etc/rc. d/init. d/mysqld start
(The above phpbb2 refers to the directory that stores the database phpbb2 .)
Yes! That's all! However, it should be noted that, for fear of the correlation between the data in each Tables in the DB, it is best to keep the entire DB one time, and only the Tables files are prepared separately, I am afraid there will be inconsistent data association issues!
Iii. How to save
In the phpBB discussion board, you only need to extract the file back to the path where the original web page is stored. Use the following command to solve the problem:
Tar xvfz phpbb2_20020601.tgz
When a DB error occurs and you need to store it back, it is not difficult. First, find the latest complete and normal backup, and first rename or tar the current incorrect webpage or DB, you can just undo the backup to the original directory location. It is important to note that the MySQL service should also be stopped first, and then start the service after the data is saved, the entire program for storing the database back may look like the following:
/Etc/rc. d/init. d/mysqld. stop
Mv phpbb2 phpbb2_error
Tar xvfz phpbb2_db_20020601.tgz
/Etc/rc. d/init. d/mysqld. start
Then, test the webpage and database! You can check whether the application is normal...