#Yii Solution: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Updated November 30, 2013 ● 3,592 views

This is a short guide to all fellow Yii developers out there or PHP developers in general. It took me a good hour to resolve the issue when all of a sudden, Oauth login is throwing out an error when it's trying to validate against the MySQL database.

The MySQL error is:

[exception.CDbException] exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away'

So obviously, it'a saying that the connection to MySQL has been lost. So this is all about connection timeout. There are several timeout configurations in MySQL.

Searching Google gave me a couple of suggestions from adjusting MySQL configurations such as max_allowed_packet, connect_timeout, etc. Some of the changes didn't workout until I tried to change wait_timeout.

My original wait_timeout was set to 20. I changed it to 60 seconds and it's back to normal again:



Our Terms of Use and Privacy Policy have changed.
By continuing to use this site, you are agreeing to the new Privacy Policy and Terms of Service.