Learning Mysql



Download 4.24 Mb.
View original pdf
Page335/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   331   332   333   334   335   336   337   338   ...   366
Learning MySQL
The Binary Log | 365

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 the
SQL statements from all the binary logs, and the pipe symbol (
|
) to pass them to the monitor in batch mode mysqlbinlog hostname-bin.* | mysql
The asterisk wildcard character (
*
) tells the operating system to read all the files that have names starting with .
Checking and Repairing Corrupted Tables
Problems 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 TABLE
com- 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 TABLE
command:

Download 4.24 Mb.

Share with your friends:
1   ...   331   332   333   334   335   336   337   338   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page