How To Restore A Table

Table of contents:

How To Restore A Table
How To Restore A Table

Video: How To Restore A Table

Video: How To Restore A Table
Video: How to restore an old table for beginner 2024, May
Anonim

Today MySQL is one of the most popular solutions among small and medium-sized database management systems. One of the advantages of MySQL is the ability to work with tables of different types. One of them is MyISAM. Such tables are great for storing frequently requested data, but if they fail during the modification process, they can be easily damaged. Therefore, there are often cases when you need to restore a table of the MyISAM type.

How to restore a table
How to restore a table

Necessary

  • - root credentials on the target machine;
  • - installed package of MySQL server administration utilities.

Instructions

Step 1

Start a session with the credentials of the root user on a machine with a functioning MySQL server running a database that is believed to have corrupted tables. If you can work directly with the target computer, log in to a text console or run a terminal emulator as root. If you have remote SSH access, use an appropriate client program to make the connection.

Step 2

Stop the MySQL database server on the target machine. Run the service mysqld stop command. Wait for the shutdown process to complete (this will be indicated by a diagnostic message).

Step 3

Create a backup copy of the database table files, which will be used for further work. In this case, it is convenient to use the file manager. Navigate to the folder containing the table files. It has a name identical to the name of the database and is located in the db directory, which is located in the root directory of the server (addressed by the chroot variable of the my.cnf configuration file). Copy all files with extensions MYD and MYI from the current folder to some temporary directory.

Step 4

Check one or more database tables for damage. In the current directory, run the myisamchk command with the -c option (or no options at all) for a normal scan. Use the -m option for careful testing, and the -e option for extra careful testing. As the last parameter, specify the name or mask of the names of the files to be processed. For example: myisamchk -c test_table. MYImyisamchk *. MYI

Step 5

Recover the table or tables where the damage was found. Run the myisamchk command with the -r option for normal recovery, or the -o option for gentle recovery. As the last parameter, as in the previous step, pass the name or name mask of the target tables. For example: myisamchk -o test_table. MYI

Step 6

Start the MySQL server. Run the service mysqld start command.

Step 7

End your session. Enter the command exit and press Enter.

Recommended: