Mysql myisamchk fixes Common Database Command records

Source: Internet
Author: User

If a problem occurs in the database or data table in mysql, we can use the myisamchk command to modify it. Next I will introduce the usage of the myisamchk command.

Instance

The Code is as follows: Copy code

# Locate myisamchk

# Ln-s/usr/local/mysql/bin/myisamchk/usr/bin/myisamchk

# Myisamchk tablename. MYI

# Myisamchk-r-q tablename

If-r doesn't work, execute the following command forcibly:

The Code is as follows: Copy code

# Myisamchk-r-o-f

Now, let's share an instance.


MyISAM is the default storage engine. MyISAM table of MySQL ).
This article will teach you how to check/repair? What kind of information can I do if I'm a camgirl? YISAM tables.

Every time you go to MySQL DB? Create a table, which will be stored in the file system at the same time? Create files in three formats: *. frm, *. MYD, and *. MYI.

*. Frm = file to store table format)
*. MYD (MyData) = used to store data (file to store data)
*. MYI (MyIndex) = used to store the index (file to store index)

How to check the database? Which table needs to be repaired? Stop? /P>

Run the following command with root: Check the tables in DB1

The Code is as follows: Copy code

# Myisamchk/var/lib/mysql/DB1/*. MYI & gt;/tmp/myisamchk. log

In the screen output, if the following words are found, the data table should be repaired ?? /P>

The Code is as follows: Copy code

Myisamchk: error: Keypointers and record positions doesn't match
MyISAM-table '/var/lib/mysql/DB1/news_post_comment.myi' is already upted
Fix it using switch "-r" or "-o"
Myisamchk: warning: 1 client is using or hasn' t closed the table properly
MyISAM-table '/var/lib/mysql/DB1/news_post.myi' is usable but shoshould be fixed
Myisamchk: warning: 1 client is using or hasn' t closed the table properly
MyISAM-table '/var/lib/mysql/DB1/news_post_push_log.myi' is usable but shoshould be fixed

More information is displayed in the Redirect File. As follows:

The Code is as follows: Copy code

Checking MyISAM file:/var/lib/mysql/DB1/yam_bbauth.MYI
Data records: 14 Deleted blocks: 0
-Check file-size
-Check record delete-chain
-Check key delete-chain
-Check index reference
-Check data record references index: 1
-Check record links

How to Use myisamchk for repair? Tu Meizhen? Ables:

Run the following command to repair the corrupted table? Stop? /P>

The Code is as follows: Copy code

# Myisamchk-r/var/lib/mysql/DB1/news_post_comment.MYI
-Recovering (with sort) MyISAM-table '/var/lib/mysql/DB1/news_post_comment.MYI
Data records: 1
-Fixing index 1

If the table is being used by an application, you may see that clients are using or haven'tclosed the table properly.
So it is recommended to repair? Too many? Disable ysqld or use flush tables to lock TABLES to prevent repair? Shadow? Pplication changes the database TABLE.

How to check and repair? Tun? Benzene? School? /P>

The Code is as follows: Copy code

# Myisamchk -- silent -- force -- fast -- update-state/var/lib/mysql/DB1/*. MYI
Myisamchk: MyISAM file/var/lib/mysql/DB1/groups. MYI
Myisamchk: warning: 1 client is using or hasn' t closed the table properly
Myisamchk: MyISAM file/var/lib/mysql/DB1/profiles. MYI
Myisamchk: warning: 1 client is using or hasn' t closed the table properly

The meaning of options is as follows:
? S,-silent option: Prints only errors. You can use two-s to make myisamchk very silent.
? -F,-force option: Restart myisamchk automatically with repair option-r, if there are any errors in the table.
? -F,-fast option: Check only tables that haven'tbeen closed properly.
? -U-update-state option: Marks tables as crashed, when it finds any error.

Repair? Fading? Are there any other problems? Yo? B

Large table, repair? Token? Why? Are you sure you want to continue? Why ?? /P>

The Code is as follows: Copy code
# Myisamchk -- silent -- force -- fast -- update-state -- key_buffer_size = 512 M -- sort_buffer_size = 512 M
-- Read_buffer_size = 4 M -- write_buffer_size = 4 M/var/lib/mysql/DB1/*. MYI

Use myisamchk to obtain table information

The Code is as follows: Copy code

# Myisamchk-dvv profiles. MYI
MyISAM file: profiles. MYI
Record format: Packed
Character set: latin1_swedish_ci (8)
File-version: 1
Creation time: 2007-08-16 18:46:59
Status: open, changed, analyzed, optimized keys, sorted index pages
Auto increment key: 1 Last value: 88
Data records: 88 Deleted blocks: 0
Datafile parts: 118 Deleted data: 0
Datafile pointer (bytes): 4 Keyfile pointer (bytes): 4
Datafile length: 6292 Keyfile length: 6144
Max datafile length: 4294967294 Max keyfile length: 4398046510079
Recordlength: 2124

Table description:
Key Start Len Index Type Rec/key Root Blocksize
1 2 3 unique int24 1 1024 1024
2 5 765 unique char packed stripped 1 2048 4096

Field Start Length Nullpos Nullbit Type

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.