> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.serverfreak.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How Do I Optimize a MySQL Database Table via Command Line?

To optimize a mysql database table via command line you will need to ssh into your server as the root user and enter into the mySQL command line interface by typing "mysql". This will give you the following prompt.

**mysql** >

Once you are at a mySQL command prompt you will need to type the following. The first selects the database you wish to use and the second optimizes the table(s).


**mysql> USE your_database;**
**Database changed**



**mysql> OPTIMIZE TABLE `table1` , `table2` , `table3` , `table4` ;**