MySQL Cheat Sheet

Submitted by Stefan Schneider on Wed, 03/24/2010 - 09:38

This is the cheat sheet of an "Adhoc" MySQL system administrator like me...

Creating and Dropping of Databases

mysql> create database database name;

mysql> drop database database name;

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| holodoctor |

| mysql |

| test |

+--------------------+

4 rows in set (0.02 sec)

Purging old bin-logs

Non disclaimer: This operation may corrupt your database. Be very careful and study the manuals upfront! Having bin logs enabled will allow to recover from crashes without data loss. They grow however over time and they may fill up the entire available disk space. The strategy is to check their size in

mysql: mysql> show master logs;

Teach MySQL first to not use bin logs older then a given one (here: mysql-bin.000050)

mysql> purge master logs to 'mysql-bin.000050';

Reorganizing Tables

mysqlcheck -oA -u root -p