Problems with MySQL table optimisation

Example:

mysql> optimize table wp_actionscheduler_actions;
+-------------------------------------------+----------+----------+-------------------------------------------------------------------+
| Table                                     | Op       | Msg_type | Msg_text                                                          |
+-------------------------------------------+----------+----------+-------------------------------------------------------------------+
| products_wp.wp_actionscheduler_actions | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| products_wp.wp_actionscheduler_actions | optimize | error    | Invalid default value for 'scheduled_date_gmt'                    |
| products_wp.wp_actionscheduler_actions | optimize | status   | Operation failed                                                  |

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

3 rows in set, 2 warnings (0.02 sec)

Solve this first:

Invalid default value for ‘scheduled_date_gmt’

SET SQL_MODE='ALLOW_INVALID_DATES';

Next you’ll see this:

mysql> SET SQL_MODE='ALLOW_INVALID_DATES';

Query OK, 0 rows affected (0.01 sec)

mysql> optimize table wp_actionscheduler_actions;
+-------------------------------------------+----------+----------+-------------------------------------------------------------------+
| Table                                     | Op       | Msg_type | Msg_text                                                          |
+-------------------------------------------+----------+----------+-------------------------------------------------------------------+
| products_wp.wp_actionscheduler_actions | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| products_wp.wp_actionscheduler_actions | optimize | status   | OK                                                                |
+-------------------------------------------+----------+----------+-------------------------------------------------------------------+
2 rows in set (2.02 sec)

Done.

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top