CREATE TABLE artist (
`artist_id` smallint(5) NOT NULL default '0',
`artist_name` char)
default NULL,
PRIMARY KEY (`artist_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
# at 30794
#060625 17:42:41 server id 1 end_log_pos 30903 Query thread_id=168
exec_time=0 error_code=0
SET TIMESTAMP=1151221361;
Note that the text between the
/*! ... symbols contains
MySQL-specific instructions, as described in Exploring Databases and Tables with SHOW and mysqlshow”
in Chapter You should create regular dumps of the database using mysqldump with the flush- logs option. In the event of a disaster, you can follow the instructions described earlier in Loading Data from an SQL Dump File to restore the database to the state it was at the time you generated the dump file. You can then
use mysqlbinlog to extract theSQL statements from all the binary logs, and the pipe symbol (
|
) to pass them
to the monitor in batch mode mysqlbinlog hostname-bin.* | mysqlThe asterisk wildcard character (
*
) tells the operating system to read all the files that have names starting with
.
Checking and Repairing Corrupted TablesProblems such as running out of disk space or a power failure could cause your databases files to be corrupted in these cases, the server will often not have written all transactions to disk. It’s a good idea to check the tables before you start to use them again. Repairing tables will not guarantee
that no data will be lost, but it does allow you to use the database again without losing anymore data.
One way to check and repair tables is to use the CHECK TABLE
and
REPAIR TABLEcom- mands from the monitor. For example, to check the artist
table in the music database,
you would write:
mysql>
CHECK TABLE music.artist;+--------------+-------+----------+------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------+-------+----------+------------------------------+
| music.artist | check | error | Checksum for key 1 doesn't |
| | | | match checksum for records |
| music.artist | check | error | Corrupt |
+--------------+-------+----------+------------------------------+
2 rows inset sec)
In this example, the table is damaged you can repair
it using the REPAIR TABLEcommand:
Share with your friends: