Difference between revisions of "MySQL Troubleshooting"
(Created page with "= MySQL Troubleshooting = == InnoDB Disabled == Run this command in SSH as root to show the current engines: mysql -e "show engines;" If you run a mysqcheck and get somethi...") |
(No difference)
|
Revision as of 20:12, 26 October 2011
Contents
MySQL Troubleshooting
InnoDB Disabled
Run this command in SSH as root to show the current engines:
mysql -e "show engines;"
If you run a mysqcheck and get something like the following on a number of tables:
Error : Incorrect information in file: './halp_blah/example_innodb.frm' error : Corrupt
The tables are not actually corrupt, they are just InnoDB tables and InnoDB is disabled.
Locked Tables
http://dev.mysql.com/doc/refman/5.0/en/table-locking.html
If you see MANY locks on a table (or tables, specifically MyISAM not InnoDB), the option low_priority_updates may help. If it is enabled, selects will get higher priority than updates and waiting updates will not stall all new selects to the table until they are executed.
low_priority_updates = 1
Post-Upgrade - MySQL does not start
If you get the following error message why trying to start MySQL 5.x after an upgrade:
Starting MySQL Couldn't find MySQL manager or server [FAILED]
Then edit /etc/my.cnf and comment out the following line:
basedir=/var/lib
Then restart MySQL.
MySQL Top Resources Script
mysqladmin processlist | cut -d"|" -f3 | sort | uniq -c | sort -n | tail -n 8
MySQL Datadir Migration
mkdir -p /home/mysql chown mysql:mysql /home/mysql rsync -avHl /var/lib/mysql/ /home/mysql/ /etc/init.d/{crond,mysql} stop rsync -avHl /var/lib/mysql/ /home/mysql/ mv /var/lib/mysql /var/lib/mysql.bak ln -sf /home/mysql /var/lib/mysql
If /var is full
rsync -avHlT /home/rtmp$$ /var/lib/mysql/ /home/mysql/
Post-migration
[mysqld] datadir=/home/mysql #basedir=/var/lib/mysql
It should then be safe to restart MySQL:
/etc/init.d/{crond,mysql} start rm -rf /var/lib/mysql.bak rm -f /home/mysql/*.pid touch /home/mysql/$(hostname).pid
Database Repair
Run this first to determine which tables are corrupted:
mysqlcheck -Asc
Repair Corrupted Database (REPAIR)
mysqlcheck -r <database name>