Myq Server Not Responding Please Try Again Later

"MySQL server has gone away" fault – Solution(s)

The MySQL server has gone abroad error, ways that MySQL server (mysqld) timed out and airtight the connection. Past default, MySQL volition close connections after 8 hours (28800 seconds) if nothing happens. However, in some cases, your web host, DBA, or app developer may have decreased this timeout setting, discussed below.

MySQL server has gone away, tin can be a frustrating error to solve. This is partly because to solve this error; sometimes the solution involves multiple layers, application, or service config changes. This article includes solutions I've seen for this MySQL server general error. If you've found a solution not listed or linked to on this page, please send me a notation or get out a comment.

MySQL server has gone away

MySQL server has gone away error log examples.

Continue in mind that this fault tin can exist logged in a few ways, as listed below. In addition, at times, the mistake is only an indication of a deeper underlying issue. Meaning the fault could be due to a trouble or bug in your connecting application or remote service. In which case, yous need to cheque ALL related mistake logs with the same timestamp to decide whether some other upshot may be to blame. Application Performance Monitoring solutions and PHP Stack trace tools can be of aid. With this in heed, here are error log examples of the MySQL server has gone away error:

General error: 2006 MySQL server has gone away
Error Code: 2013. Lost connection to MySQL server during query
Alert: Fault while sending QUERY packet
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

MySQL wait_timeout

The reason for MySQL server has gone away fault is ofttimes because MySQL'southward wait_timeout was exceeded. MySQL wait_timeout is the number of seconds the server waits for action on a non-interactive connexion before closing it. You should make certain thewait_timeout is not prepare likewise low. The default for MySQL wait_timeout is 28800 seconds. Frequently, information technology gets lowered arbitrarily. That said, the lower you can prepare wait_timeout without affecting database connections, tin be a proficient sign of MySQL database efficiency. Also, bank check the variables:net_read_timeout,net_write_timeout andinteractive_timeout. Accommodate or add the following lines in my.cnf to come across your requirements:

wait_timeout=90 net_read_timeout=90 net_write_timeout=90 interactive_timeout=300 connect_timeout=90

MySQL connect timeout in PHP config

Take a look at your php.ini config file. You lot'll notice MySQL configuration options. Make certain themysql.connect_timeout setting isn't set lower than MySQL wait_timeout, discussed above. The PHP optionmysql.connect_timeout is non only used for connect timeout. It's also when waiting for the outset response from the MySQL server. Try increasingmysql.connect_timeout to match or exceed your MySQL wait_timeout and make sure that mysql.allow_persistent is on (default = enabled).

mysql.connect_timeout=90 mysql.allow_persistent=1

IMPORTANT: Read first nearly PHP Persistent Database Connections to understand the benefits and caveats.

Likewise, adjust PHP'sdefault_socket_timeout. For case, a PHP script could be running a dull query. Creating a wait that utilizes the default_socket_timeout. Eventually, it quits with the "MySQL server has gone abroad" error. Before you lot send detest postal service, please read here first. Here's an extract:

"PHP, past default, sets a read timeout of 60s for streams. This is set viaphp.ini, default_socket_timeout. This default applies to all streams that ready no other timeout value. mysqlnd does non set whatever other value and therefore connections of long running queries tin can be disconnected later on default_socket_timeout seconds resulting in an error message2006 – MySQL Server has gone away ."

default_socket_timeout=90

To be throughout, also accommodatemax_execution_time andmax_input_time still in php.ini, if necessary. If PHP's execution time is longer than max_execution_time, then MySQL server might disconnect.

max_execution_time = 90 max_input_time = 90

MySQL max_allowed_packet

max_allowed_packet is the maximum size of one bundle. The default size of 4MB helps the MySQL server grab large (possibly incorrect) packets. Equally of MySQL 8, the default has been increased to 16MB. If mysqld receives a bundle that is as well large, it assumes that something is wrong and closes the connectedness. To fix this, you should increase the max_allowed_packet in my.cnf, and then restart MySQL. The max for this setting is 1GB. For example:

max_allowed_packet = 512M

MySQL innodb_log_file_size

You may need to increment theinnodb_log_file_size MySQL variable in your my.cnf configuration. MySQL'sinnodb_log_file_size should be 25% ofinnodb_buffer_pool_size (if possible, no less than 20%). Remember that the larger this value, the longer it will take to recover from a database crash. (Source: Phpmyadmin Advisor)

This means for example: if your buffer pool size is set to innodb_buffer_pool_size=16G  and yourinnodb_log_files_in_group setting is still set up to the recommended default of 2 files (innodb_log_files_in_group=2), and so yourinnodb_log_file_size should exist ready to 2G. This volition create ii (2) log files at 2GB each, which equals 25% ofinnodb_buffer_pool_size=16G .

WARNING:You must stop MySQL server in order to changeinnodb_log_file_size orinnodb_log_files_in_group. If you don't, you take chances catastrophe! (Read: MySQL Log Redo instructions.)

Other causes of MySQL server has gone away

Remote MySQL connections

Think earlier I mentioned that the error, at times, is only an indication of a deeper underlying issue. For example, remote MySQL connections to tertiary party services. Using a 3rd political party payment processing plugin for osCommerce, Magento, etc.

MySQL database charset and collation

Changing default database charset to latin1 and default collation to latin1_general_ci seemed to have solved MySQL server has gone away for some.

Exceeding MySQL max_connections setting

Max_connections set the maximum permitted number of simultaneous client connections. Be careful with this setting!! Exhaustion of memory and other resources can occur when set too large and scheduling overhead also increases. As a guide, set up max_connections to approximately double the previous number of maximum simultaneous customer connections. E.g., if afterward a month of uptime, the maximum simultaneous customer connections were 114, then set up to max_connections=250. Earlier you become crazy with this setting, delight read: How MySQL Handles Client Connections.

Still unresolved? See MySQL's help page.

Oracle has put together a nice self-assistance folio for MySQL server has gone away errors. On that page, they also advise that you make sure MySQL didn't finish/restart during the query. Excerpt:

"You can check whether the MySQL server died and restarted past executing mysqladmin version  and examining the server'southward uptime. If the client connection was cleaved because mysqld  crashed and restarted, yous should concentrate on finding the reason for the crash."

# mysqladmin version mysqladmin Ver nine.ane Distrib 10.i.40-MariaDB, for Linux on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.  Server version 10.i.forty-MariaDB Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: xx days xi hours 49 min twoscore sec  Threads: v Questions: 1030744326 Deadening queries: 3343 Opens: 3585 Flush tables: 1 Open tables: 2564 Queries per second avg: 582.150
# mysqladmin condition Uptime: 1770590 Threads: 4 Questions: 1030752268 Slow queries: 3343 Opens: 3585 Flush tables: 1 Open up tables: 2564 Queries per second avg: 582.151

I promise this helps!


Related articles:

  • MySQL Performance Tuning: Tips, Scripts and Tools
  • Tuning MySQL: my.cnf, avoid this common pitfall!
  • MySQL Performance: Terminate hoarding. Drop unused MySQL databases

Published: June 7th, 2019 | Last updated: August tenth, 2021

Tags: apm, linux, mariadb, mysql, performance, server, sysadmins

hansenupore1964.blogspot.com

Source: https://haydenjames.io/mysql-server-has-gone-away-error-solutions/

0 Response to "Myq Server Not Responding Please Try Again Later"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel