
Add the User to Each DatabaseĪfter adding the “opt” user, scroll down to the “Add a User to a Database” section and add the “opt” user to each database you want to optimize. I usually just create a database user called “opt,” which makes it easy for me to keep track of the purpose of that database user. Scroll down to the “MySQL Users” section and add a new user.

Sign in to cPanel and in the “Databases” section click on “MySQL Databases”. The first step is to create a database user for the optimization script to use. Create the cron job to run the PHP optimization script.Create the PHP script to for the optimization.

Add the database user to each database to be optimized.Create a database user for the optimization operation.I had a client ask about the script I use, and I’ve decided to share it here. I came up with one using a combination of cron and PHP that has worked well for me for years. Some of my clients have multiple databases and each of those had multiple tables.

When I first started out, MyISAM was the database storage engine standard for MySQL, and I used to do the table optimization manually, then phpMyAdmin came along and I began using its user interface, but that quickly became impractical as my client base grew. I’ve always been diligent about optimizing my clients’ MySQL database tables on a regular basis to reduce storage space and improve input/output efficiency.
