MyBB Community Forums

Full Version: DB - optimise cron job?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey guys,

I'd like to optimize my database hourly or so? (What's a good time?)

How do I set my cron job to do this? The database name is 'gamingb2_forums'
Give me an admin test login I will do.
Just tell me what I need to do?
Do you mean cron in the OS or in MyBB??

If on linux, you can setup a cron to optimize the tables using the mysqlcheck utility which comes standard with the mysql installation.

I would run it at a time when your board is not too busy.
Depends, which one is more preferable? I have linux so I can go with both options.

I don't really know what to type in, could you please help? Smile
I'd prefer the linux option.

A simple command would look like:

mysqlcheck -ao -u [user] -p[password] -databases DB1 DB2
The above will analyze and optimize databases DB1 and DB2 using the username/password supplied to first connect.

There are far more options in the mysqlcheck command which you can find by running mysqlcheck without any parameters.
For example, another usefull switch is --auto-repair which automatically repairs corrupted tables but I'd recommend using that with caution as you might end up with data loss if the table was too corrupted.

You'll need to set the above command in crontab of your choosing or whats available to you. You can google how to setup cron on linux if thats new to you.

Thank you. How often should it be?
Again, depends on how big/busy your forum is, once a day is more than enough IMO.
Okay, it says "mysqlcheck: unknown option '-d'"
(2011-01-03, 11:13 AM)Renegader Wrote: [ -> ]Okay, it says "mysqlcheck: unknown option '-d'"

Sorry, I missed a -
the command is supposed to be:

mysqlcheck -ao -u[user] -p[password] --databases DB1 DB2

OR the shorthand:
mysqlcheck -ao -u[user] -p[password] -B DB1 DB2

Also, the user/password is to be entered without the []
Pages: 1 2