1. online
Check table tablename
repair table tablename
2. offline
- Check all myisam table in particular database
shell> myisamchk *.MYI
- Check all myisma table in all database
shell> myisamchk /path/to/datadir/*/*.MYI
- Check and repair all myisam table
If you want to check all MyISAM tables and repair any that are corrupted, you can use the following command:
shell> myisamchk --silent --force --fast --update-state \
--key_buffer_size=64M --sort_buffer_size=64M \
--read_buffer_size=1M --write_buffer_size=1M \
/path/to/datadir/*/*.MYI
Reference
myisamchk — MyISAM Table-Maintenance Utility
Checking Tables with mysqlcheck and myisamchk
How to Repair Tables
Friday, October 09, 2009
Thursday, October 08, 2009
"MySQL server has gone away" using mysqlhotcopy
"MySQL server has gone away" using mysqlhotcopy
I add the below statement in my.cnf
[mysqlhotcopy]
interactive-timeout
and mysqlhotcopy successful
I add the below statement in my.cnf
[mysqlhotcopy]
interactive-timeout
and mysqlhotcopy successful
Thursday, October 01, 2009
show processlist and kill thread
If user not root user and no grant necessary permission,
They only allow seeing their thread when they issue "show processlist"
In order to see all threads in the server, they need "process privilege"
Logon as root and issue the below statement:
grant process on *.* to 'someone'@'%';
flush privileges;
Logon as “someone and issue the below statement:
show processlist;
All threads in mysql server will show.
We try kill one of the thread which no belong to "someone" with issue the below statement:
kill 95;
mysql give this error : You are not owner of Thread 95
If we want "someone" to kill other thread
We need to grant "super privileges"
Logon as root and issue the below statement
grant super on *.* to 'someone'@'%';
flush privileges;
Open the new connection, logon as “someone” and issue the below statement:
show processlist;
All threads in the server will be shows.
Issue the below statement to kill thread which no belong to “someone”
kill 95;
Thread Id 95 successful kill.
Notes:
- The PROCESS privilege can be used to view the plain text of currently executing statements, including statements that set or change passwords.
- The SUPER privilege can be used to terminate other sessions or change how the server operates.
- The SUPER privilege enables an account to use CHANGE MASTER TO, KILL or mysqladmin kill to kill threads belonging to other accounts (you can always kill your own threads), PURGE BINARY LOGS, configuration changes via SET GLOBAL to modify global system variables, the mysqladmin debug command, enabling or disabling logging, performing updates even if the read_only system variable is enabled, starting and stopping replication on slave servers, and allows you to connect (once) even if the connection limit controlled by the max_connections system variable is reached.
Conclusion:
If you have the PROCESS privilege, you can see all threads.
If you have the SUPER privilege, you can kill all threads and statements.
Otherwise, you can see and kill only your own threads and statements.
Reference: http://dev.mysql.com/doc/refman/4.1/en/kill.html
They only allow seeing their thread when they issue "show processlist"
In order to see all threads in the server, they need "process privilege"
Logon as root and issue the below statement:
grant process on *.* to 'someone'@'%';
flush privileges;
Logon as “someone and issue the below statement:
show processlist;
All threads in mysql server will show.
We try kill one of the thread which no belong to "someone" with issue the below statement:
kill 95;
mysql give this error : You are not owner of Thread 95
If we want "someone" to kill other thread
We need to grant "super privileges"
Logon as root and issue the below statement
grant super on *.* to 'someone'@'%';
flush privileges;
Open the new connection, logon as “someone” and issue the below statement:
show processlist;
All threads in the server will be shows.
Issue the below statement to kill thread which no belong to “someone”
kill 95;
Thread Id 95 successful kill.
Notes:
- The PROCESS privilege can be used to view the plain text of currently executing statements, including statements that set or change passwords.
- The SUPER privilege can be used to terminate other sessions or change how the server operates.
- The SUPER privilege enables an account to use CHANGE MASTER TO, KILL or mysqladmin kill to kill threads belonging to other accounts (you can always kill your own threads), PURGE BINARY LOGS, configuration changes via SET GLOBAL to modify global system variables, the mysqladmin debug command, enabling or disabling logging, performing updates even if the read_only system variable is enabled, starting and stopping replication on slave servers, and allows you to connect (once) even if the connection limit controlled by the max_connections system variable is reached.
Conclusion:
If you have the PROCESS privilege, you can see all threads.
If you have the SUPER privilege, you can kill all threads and statements.
Otherwise, you can see and kill only your own threads and statements.
Reference: http://dev.mysql.com/doc/refman/4.1/en/kill.html