• Matthew

    (@bodhidharma74)


    Hello WordPress friends

    I have come to the WordPress forums in need of some expert help. Databases and mySQL is definitely not my area of expertise so apologies for being a noob from the outset!

    Here is my problem:

    For a while now my WordPress blog’s CPU has been running very high (close to 100%) and I have received a number of warnings from my webhost. Since then I have really stripped out all unnecessary plug-ins, etc to try to reduce this high utilisation.. and this did work for a couple weeks.

    I am on a shared server.

    The other day I noticed an error_log in my root directory, and for the past three weeks there was a common error appearing, multiple times a day saying,

    “WordPress database error MySQL server has gone away for query…”

    After looking on Google I came across this article https://robsnotebook.com/wordpress-mysql-gone-away.. and a lot of other articles also point back to this one.

    The author explained,

    “When someone tries to view one of your WordPress web pages, the PHP code first opens a connection to the MySQL server. Subsequent queries to the MySQL server rely on the connection remaining open, and do not re-open the connection. If the connection to the server happened to have shut down before a query is made, then WordPress will display this error.”

    His solution/workaround was to increase a timeout variable in the wp-db.php file by adding the following code,

    $this->query(“set session wait_timeout=600”);

    Since adding this code these error messages have disappeared.. but a new one has replaced it,

    [16-Apr-2010 01:03:36] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1 for query set session wait_timeout=600 made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, wp_related_posts, wp_get_related_posts

    [16-Apr-2010 10:56:00] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE meta_key = ‘_wp_trash_meta_time’ AND meta_value < ‘1268787359” at line 1 for query set session wait_timeout=600 made by do_action_ref_array, call_user_func_array, wp_scheduled_delete

    This is now the only error that appears (a couples times every day).

    I am running MySQL version 5.0.90

    Does anyone know what this means and how to resolve this?

    Many thanks,
    Matt

  • The topic ‘WordPress database error You have an error in your SQL syntax’ is closed to new replies.