I moved a site from one server to another server (both dedicated servers, WHM). I used WHM's copy account process and then updated settings.php and emptied cache, watchdog, session tables. However, I am getting the error below.

The error only occurs when I try to login to the site. This is the error below:

Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {cache} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => entity\_info:% ) in cache_clear_all() (line 176 of /home/mysite/public_html/includes/cache.inc).
Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:221:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {cache} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => entity\_info:% ) ";s:9:"%function";s:17:"cache_clear_all()";s:5:"%file";s:45:"/home/mysite/public_html/includes/cache.inc";s:5:"%line";i:176;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://mysite.com.au/ [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 124.171.42.187 [:db_insert_placeholder_9] => 1338541475 ) in dblog_watchdog() (line 154 of /home/mysite/public_html/modules/dblog/dblog.module).
________________________________________
Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in _drupal_session_write() (line 209 of /home/mysite/public_html/includes/session.inc).

We are in the middle of site transfer and there is possibility of downtime due to this issue. I have searched everywhere but can't find a definite answer.

Will appreciate help with this.

Cheers

Comments

donutdan4114’s picture

The most obvious thing to me would be that the settings in your settings.php are wrong. Can you connect to MySQL in any other way to verify the host/port?

Given your error message, the issue is that Drupal can't even connect to the database, so probably the host/port option is wrong.

More info can be found on the MySQL site:
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

standingtall’s picture

Unfortunately, that's not the case. I have changed settings.php and used a wrong password deliberately and it gives a wrong password error. Also, it shows posts on home page and user data which would not have been possible if Drupal was not connecting to MYSQL.

There are a lot of posts on Drupal.org about this issue with NO reliable solution given anywhere.

cweagans’s picture

Priority: Critical » Normal

Support requests are neither major nor critical.

standingtall’s picture

Category: support » bug

I think this is a bug which is being faced by many people.

cweagans’s picture

Category: bug » support

This is not a bug with Drupal and appears to be related to your MySQL configuration. I would suggest bumping the max_allowed_packet up to something like 32M or even 64M. Also of interest is your key_buffer_size: bumping that up may help as well.

It's basically a matter of having too much going on in your Drupal site for your MySQL configuration. Give your DB more resources and the problem will go away.

PROMES’s picture

Thanks cweagans,
This helped me to find the reason I got this error on my conversion testserver. I knew MySQL was working because a lot of data allready was fetched from the database and then the db went away in the next query.
My MySQL-ini file had a key_buffer of 1M. By bumping it up to 32M the problem disappeared.
I have been looking for the reason and a solution for several weeks and was looking at the wrong places. Mostly I didn't get an error at all but only a blank screen.

For those not aware of the possible MySQL configurations:
Looking in the several MySQL ini-files in my XAMPP installation learned me the main difference in all ini-files is the key_buffer size. In the ini-files the key_buffer is:
my-small.ini: 1M
my-medium.ini: 16M
my-large.ini: 256M
my-huge.ini: 384M
I hope this maybe of help for other Drupallers.

standingtall’s picture

It has NOTHING to do with MYSQL configuration. Apparently, Backup and Migrate module is ruining DB tables and that triggers this error.

I resolved the issue by following the solution below:
http://drupal.org/node/1100146

PROMES’s picture

So you see some errors have more then one reason.
At last my problem was solved by updating the mysql settings.

cweagans’s picture

Er, no. That issue that you linked had the mysql error "PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: ...". You were getting a MySQL server has gone away error. Two different issues with two different solutions.

Glad you got it fixed though.

hza1’s picture

I met a similar problem lately.....

I installed a new module "Drupal Commerce".

When I enable some functions of the module "Drupal Commerce", this problem occurred.

Thanks cweagans, just as he said.

The key is max_allowed_packet of mysql settings. Bump it up ,and done.

djkentuckyham’s picture

@hza1. Cheers. You really saved my bacon with that DC recco. I was getting MySql errors post creation of a Drupal Commerce Product Type. All is well now.

Version: 7.14 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

andsigno82’s picture

cweagans with #5 was absolutely right!

longwave’s picture

Status: Active » Fixed

This is a very old support request and the original issue is long since fixed, so let's close this ticket off.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.