I get the error PDOException: SQLSTATE[HY000]: General error: 2006 MySQL
The solution could me increasing max_allowed_packet but the problem is that I use shared server. They told me it cannot be change and the problem is in my script. I didnt change nothing in database during the period when the problem occured. I checked the permission of the files, looks like everything is ok.
Please help.

Comments

David910’s picture

You create your own my.cnf:

1) Create a "my.cnf" file in "/Applications/MAMP/conf/", or copy one of the "*.cnf" files from "/Applications/MAMP/Library/support-files/" to "/Applications/MAMP/conf/" and rename it to "my.cnf".
2) Add/Modify your settings in the "my.cnf" file.
3) Save the "my.cnf" file.
4) Restart the servers.
P/s: You don't need to add all the parameters in the "my.cnf" file.

===============================
http://www.academy-review.com/

John_B’s picture

I reported the suggestion above as spam partly because it is copied and pasted from https://www.drupal.org/node/984112#comment-4694182 and is irrelevant; partly because the signature contains a link to a non-Drupal marketing site.

I don't really have a better solution. What I will say is that if your website is at all important to you or your business it worth accepting that fact that there is no way to avoid paying for quality hosting. However, if the hosting is good in other ways (fast, reliable, good support), before moving it migh tbe worth tracking down what specific situation this error arises in. That will at least tell what you to look for in a new host, even if the problem cannot be removed.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

nellngun’s picture

Thnaks! I use pro version of hosting for a buisness cumstomers with max_allowed_packet=16M... Is there a possibily to lower received packet that my website is producing?

John_B’s picture

Is there a possibily to lower received packet that my website is producing?

I don't really understand the question, and I am tempted to say 'no' with an element of guessing. If you think about it, it is very unusual for a Drupal site to need to store a single data object which is more than 16MB. Whilst it would be nice to be on hosting where you can do what you like in that sense, I would still be surprised if increasing maximum_allowed_packet would fix the problem, a I would still want to know what piece of data in the database is more than 16MB. My view is that you need more accurate diagnosis of exactly what is causing the problem, before going in and changing mysql settings, even supposing you had access to do so on the server.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

nellngun’s picture

Many thanks, please provide me with information how can I check it. The accesslog table is over 50MB can it occurs the problem?
I attamped to ask how I can minimalize my data that the problem won't occur?

John_B’s picture

The first question to ask yourself is, what situation are you getting the error in? Can you reproduce it reliably? Is there another version of the same error in the server error logs? These kind of questions are the beginning, and it becomes a tutorial in debugging if we are not carefull! Unfortunately the error message you have reported so far is so general it does not give much to go on.

One of the questions I would be asking is whether this error is intermittent or is restricted to the hosted copy of the site, in which case I would suspect their database server is either inadequate or is being abused by a neighbour on the hosting. On the other hand, if the error can be reproduced reliably, and especially if it can be reproduced on a local copy of the site on your laptop, then you are looking for something specific about your site which is causing the error.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

nellngun’s picture

Ok, so the error is as below. I wrote to the hosting provider but they didnt respond, it has been over two weeks since the error occured and it drives me nuts. I digged through many topics containing the error below and the only solution I found was to increase max_allowed_packet

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => pl [:source] => Role [user:role-changed] added for [user:name] at [site:name] [:context] => ) in locale() (line 720 of /home/xxx/xxx/modules/locale/locale.module).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => pl [:source] => Before adding a product to the cart [:context] => ) in locale() (line 720 of /home/xxx/xxx/modules/locale/locale.module).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] => upeYBT2prWUJN6GpI79_ueGavy5evo-ygoxcF9lBXtM [:db_condition_placeholder_1] => MZCJEtQpC1DowOBCCwIsRr9mE1ZGgr8FMxeWjivSD8I ) in _drupal_session_write() (line 209 of /home/xxx/xxx/includes/session.inc).

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 25339922558ec970135c274.54166670 ) in lock_release_all() (line 275 of /home/xxx/xxx/includes/lock.inc).

John_B’s picture

Basically the mysql server is crashing. In this case it is almost certainly not crashing because you are trying to write too big a piece of data, and increasing the maximum allowed packet will make no difference.

I also doubt whether it is a problem with your site, though I am less certain about this. If you put the site on a laptop it will probably work. I suspect that the problem is that the site is on hosting which is of poor quality; or the hosting support has failed to sort out a neighbouring site on the server which is abusing the database. If you want to test this theory, put a copy of a the site on a different server or a suitable laptop and check it.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

nellngun’s picture

Ok, so nothing still. The website is working like once per 10 refreshing. Its driving me crazy becasue the users keep writing me and I still didnt find any solution for that. My hosting is not replying. I downloaded acquia drupal but I have problem with installing it properly, there is some conflicts with https.
The problem occured very strange. Firstly sent me some Ip conflicts during visiting my page in chrome, when I restarted the routher, everything was ok. Next week starts to occur HTTP error 500. The error was exposing for user 1 during other users were using the website as usual. Next it occurs for everyone mixing with 504 Server getaway.
And for example in that particular moment the website is working as nothing happen during 5 min and again finally crashing after clicking some links.
Im worry that im losing my time for searching solution when it might be a server problem.

John_B’s picture

there is some conflicts with https.

Shouldn't be. Did you clear caches? Anyway, it might be worth taking a server or alternative hosting for a month at least to test.

My hosting is not replying.

A good reason for moving the site, even if it is not their fault.

504 Server getaway.

That is usually a hosting problem. Not always.

You do need to be able to move the site to a different server or a laptop--whether or not Acquia Dev Desktop is what works for you. After all, you might need to restore a backup, and your hosting company could go down. And it is risky to work on a live site. I know that if you are not in the habit of moving a site it can be a lot of work, although once you get set up with drush and the relevant drush skills it can be very fast. So although this is frustrating, it is a barrier worth overcoming independently of this particular issue.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

HongPong’s picture

This thread was helpful for me. I had run a server update and it started erratically saying the server went away but only on some paths. With Apache and mariadb installed in centos.

General error: 2006 MySQL server has gone away

was the main error.

also MariaDB error may be solved with : SET GLOBAL max_allowed_packet = 1024 * 1024 * 512;

In centOS edit /etc/my.cnf add the following in the [mysqld] area.

max_allowed_packet=64M