[SOLVED][Drupal Errors] MySQL: "Warning: MySQL server has gone away"

| | 2 min read

Many Drupal programmers, Drupal site admins and Drupal site users have encountered the error message - "MySQL: "Warning: MySQL server has gone away" on their Drupal site. If you are facing the same situation in your Drupal site then read on to know the fix.

The error is usually caused by a lack of insufficient resources available to MySQL for supporting Drupal. The error can be solved by allocating more resources to MySQL by changing the settings in the configuration file. Follow the steps below to do so.

  • The MySQl configuration file in Windows is situated in C:\Program Files\MySQL\MySQL Server X.Y\my.ini
  • Linux users can find the global settings file in /etc/mysql/my.cnf
  • Create a backup of the file
  • Edit the file and add or modify the following details to the files if you are using MyISAM database tables
    [mysqld]
    
    port		= 3306
    socket		= /tmp/mysql.sock
    skip-locking
    key_buffer = 384M
    max_allowed_packet = 64M
    table_cache = 4096
    sort_buffer_size = 2M
    read_buffer_size = 2M
    read_rnd_buffer_size = 64M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    query_cache_size = 32M
  • Try changing from MyISAM database tables to InnoDB as the former is more resource intensive if you are not presently using it.
  • Here are the specifications for InnoDB database tables
  • For InnoDB specifications
    innodb_buffer_pool_size = 384M
    innodb_additional_mem_pool_size = 20M
    innodb_log_file_size = 10M
    innodb_log_buffer_size = 64M
    innodb_flush_log_at_trx_commit = 1
    innodb_lock_wait_timeout = 180
  • You must modify the above resource specifications or add them there if they are not present there as some configurations do not have them by default.

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.