Re: Druapal server fatal error: "MySQL server has gone away", but DB server is still up & accessible. Help troubleshooting?

Jamie Holly <[email protected]>
Newsgroups gmane.comp.php.drupal.support
Message-ID <[email protected]>
When it happens, run:

mysqladmin version

And check the uptime. Even though you are seeing the tables with 
mysqlshow, that doesn't mean that MySQL didn't die and then restart 
automatically when the error hit.

You can try start mysql with -log-warnings=2, which has MySQL log more 
info on problems, especially connection issues.

If none of that helps, then start mysql with the --log={file name} 
option. This will log all queries to the file you specify. You can then 
see which query it is dying on.

One other thing that you can try is changing the DB host from localhost 
to 127.0.0.1. Sometimes you can have weird problems on the server that 
causes localhost to have problems and a common reason for "mysql has 
gone away" is hostname problems (log-warnings will help identify this).

Unfortunately this is one of those problems that is a PITA to track 
down. It's not Drupal or even PHP, but rather MySQL. I recently had to 
track the same problem down on a Java application and it added to the 
gray hairs on my head.

Jamie Holly
http://hollyit.net

On 6/13/2014 10:53 PM, [email protected] wrote:
> On Fri, Jun 13, 2014, at 05:59 AM, Maina wrote:
> > Since you adjusted the 'max_allowed_packet' make sure that you restart
> > your Web Server. If you already did and still no effect, try running
> > the "update.php" file of Drupal and see if that helps.
>
> I decided to simplify matters, and take my current install out of the
> equation.
>
> Doing, instead, a completely NEW install from clean source, after a
> clean/new install of MariaDB *and* it's datadir&files, I see the SAME
> error:
>
>      SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
>
> here's what I've done:
>
> which drush
> 	/srv/www/drush/drush
> cd `which drush`
> git log | head
> 	commit c75ae2dc7a40e206c210431fbfda93cc9d1c0109
> 	Author: Moshe Weitzman <[email protected]>
> 	Date:   Fri Jun 13 08:39:55 2014 -0400
>
> 	    Fix #637. Avoid tput if TERM is 'unknown'
>
> 	commit f13c2481214d787978789596b4f54fb9b9e9fdf9
> 	Merge: fe78e58 87be1ac
> 	Author: Jonathan Hedstrom <[email protected]>
> 	Date:   Tue Jun 10 12:56:42 2014 -0700
>
> drush --version
> 	Drush Version   :  7.0-dev
>
> export myROOT="/srv/www"
> export myPROJ="Drupal7"
> export myVER="7.x"
> export mySITE="Site Name"
> export myMAIL="grantk@localhost"
> export mySUBDIR="dev"
> export myDB="dTEST01_db"
> export myUSRdb="dbUSR"
> export myPWDdb="dbPASS
> export myUSRadm="admUSR"
> export myPWDadm="admPASS"
>
>
> cd ~
> mysqld --version
> 	mysqld  Ver 10.0.11-MariaDB-log for Linux on x86_64 (Source
> 	distribution)
>
> mysqladmin --force drop   ${myDB}
> mysqladmin         create ${myDB}
> mysqlshow
> 	+--------------------+
> 	|     Databases      |
> 	+--------------------+
> 	| information_schema |
> 	| mysql              |
> 	| performance_schema |
> 	| dTEST01_db         |
> 	| test               |
> 	+--------------------+
>
> mysql mysql
>    MariaDB [mysql]>
>     GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
>     LOCK TABLES, CREATE TEMPORARY TABLES ON `dTEST01_db`.* TO
>     'dbUSR'@'localhost' IDENTIFIED BY 'dbPASS';
>     FLUSH PRIVILEGES;
>     quit
>
>
> cd ${myROOT}/${myPROJ}
>
> rm -rf drupal-7*
> drush dl drupal
> 	Project drupal (7.28) downloaded to
> 	/srv/www/Drupal7/drupal-7.28.                  [success]
> 	Project drupal contains:
> 	                                         [success]
> 	 - 3 profiles: standard, minimal, testing
> 	 - 4 themes: bartik, stark, seven, garland
> 	 - 47 modules: overlay, update, path, openid, file, contextual,
> 	 dblog, options, number, list, text,
> 	field_sql_storage, field, php, simpletest, shortcut, taxonomy,
> 	toolbar, search, blog, system, filter,
> 	locale, poll, color, trigger, book, field_ui, help, aggregator,
> 	syslog, forum, contact, menu, image,
> 	translation, user, node, block, profile, comment, tracker,
> 	dashboard, rdf, statistics,
> 	drupal_system_listing_incompatible_test,
> 	drupal_system_listing_compatible_test
>
>
> cp -af drupal-7.28 ${mySUBDIR}
> cd                 ${mySUBDIR}
> cd sites/default
> cp -af default.settings.php settings.php
>
> cd ${myROOT}/${myPROJ}/${mySUBDIR}
> drush -v site-install standard -y --site-name=${mySITE}
> --sites-subdir=${mySUBDIR} --site-mail=${myMAIL}
> --db-url=mysql://${myUSRdb}:${myPWDdb}@localhost/${myDB}
> --account-name=${myUSRadm} --account-pass=${myPWDadm}
>
> 	...
> 	Initialized Drupal 7.28 root directory at /srv/www/Drupal7/dev
> 	                     [notice]
> 	Executing: mysql --defaults-extra-file=/tmp/drush_CLONbD
> 	--database=dTEST01_db --host=localhost --silent  <
> 	/tmp/drush_SuniOM
> 	You are about to create a sites/dev/settings.php file and DROP
> 	all tables in your 'dTEST01_db' database. Do you want to
> 	continue? (y/n): y
> 	Initialized Drupal site dev at sites/dev
> 	                                            [notice]
> 	Executing: mysql --defaults-extra-file=/tmp/drush_DWuUzk
> 	--database=dTEST01_db --host=localhost --silent  <
> 	/tmp/drush_eq6aRt
> 	Executing: mysql --defaults-extra-file=/tmp/drush_GZ4Tz2
> 	--database=dTEST01_db --host=localhost --silent  <
> 	/tmp/drush_gF3Szb
> 	Undefined offset: 1 site_install.drush.inc:255
> 	                                            [notice]
> 	Starting Drupal installation. This takes a few seconds ...
> 	                                         [ok]
> 	WD php: Warning: PDOStatement::execute(): MySQL server has gone
> 	away in DatabaseStatementBase->execute()  [warning]
> 	(line 2171 of
> 	/srv/www/Drupal7/dev/includes/database/database.inc).
> 	WD php: Warning: PDOStatement::execute(): Error reading result
> 	set's header in                            [warning]
> 	DatabaseStatementBase->execute() (line 2171 of
> 	/srv/www/Drupal7/dev/includes/database/database.inc).
> 	SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
> 	                                         [error]
> 	Command dispatch complete
> 	                                            [notice]
>
> checking, the mysql server is still up and accessible
>
> 	mysqlshow
> 		+--------------------+
> 		|     Databases      |
> 		+--------------------+
> 		| information_schema |
> 		| mysql              |
> 		| performance_schema |
> 		| dTEST01_db         |
> 		| test               |
> 		+--------------------+

-- 
[ Drupal support list | http://lists.drupal.org/ ]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.