Lost connection to mysql server during query как исправить

Learn how to fix lost connection to MySQL server during query error

When you run MySQL queries, sometimes you may encounter an error saying you lost connection to the MySQL server as follows:

Error Code: 2013. Lost connection to MySQL server during query

The error above commonly happens when you run a long or complex MySQL query that runs for more than a few seconds.

To fix the error, you may need to change the timeout-related global settings in your MySQL database server.

Increase the connection timeout from the command line using –connect-timeout option

If you’re accessing MySQL from the command line, then you can increase the number of seconds MySQL will wait for a connection response using the --connect-timeout option.

By default, MySQL will wait for 10 seconds before responding with a connection timeout error.

You can increase the number to 120 seconds to wait for two minutes:

mysql -uroot -proot --connect-timeout 120

You can adjust the number 120 above to the number of seconds you’d like to wait for a connection response.

Once you’re inside the mysql console, try running your query again to see if it’s completed successfully.

Using the --connect-timeout option changes the timeout seconds temporarily. It only works for the current MySQL session you’re running, so you need to use the option each time you want the connection timeout to be longer.

If you want to make a permanent change to the connection timeout variable, then you need to adjust the settings from either your MySQL database server or the GUI tool you used to access your database server.

Let’s see how to change the timeout global variables in your MySQL database server first.

Adjust the timeout global variables in your MySQL database server

MySQL database stores timeout-related global variables that you can access using the following query:

SHOW VARIABLES LIKE "%timeout";

Here’s the result from my local database. The highlighted variables are the ones you need to change to let MySQL run longer queries:

+-----------------------------------+----------+
| Variable_name                     | Value    |
+-----------------------------------+----------+
| connect_timeout                   | 10       |
| delayed_insert_timeout            | 300      |
| have_statement_timeout            | YES      |
| innodb_flush_log_at_timeout       | 1        |
| innodb_lock_wait_timeout          | 50       |
| innodb_rollback_on_timeout        | OFF      |
| interactive_timeout               | 28800    |
| lock_wait_timeout                 | 31536000 |
| mysqlx_connect_timeout            | 30       |
| mysqlx_idle_worker_thread_timeout | 60       |
| mysqlx_interactive_timeout        | 28800    |
| mysqlx_port_open_timeout          | 0        |
| mysqlx_read_timeout               | 30       |
| mysqlx_wait_timeout               | 28800    |
| mysqlx_write_timeout              | 60       |
| net_read_timeout                  | 30       |
| net_write_timeout                 | 60       |
| replica_net_timeout               | 60       |
| rpl_stop_replica_timeout          | 31536000 |
| rpl_stop_slave_timeout            | 31536000 |
| slave_net_timeout                 | 60       |
| wait_timeout                      | 28800    |
+-----------------------------------+----------+

To change the variable values, you can use the SET GLOBAL query as shown below:

SET GLOBAL connect_timeout = 600; 

The above query should adjust the connect_timeout variable value to 600 seconds. You can adjust the numbers as you see fit.

Adjust the timeout variables in your MySQL configuration files

Alternatively, if you’re using a MySQL configuration file to control the settings of your connections, then you can edit the my.cnf file (Mac) or my.ini file (Windows) used by your MySQL connection.

Open that configuration file using the text editor of your choice and try to find the following variables in mysqld :

[mysqld]
connect_timeout = 10
net_read_timeout = 30
wait_timeout = 28800
interactive_timeout = 28800

The wait_timeout and interactive_timeout variables shouldn’t cause any problem because they usually have 28800 seconds (or 8 hours) as their default value.

To prevent the timeout error, you need to increase the connect_timeout and net_read_timeout variable values. I’d suggest setting it to at least 600 seconds (10 minutes)

If you’re using GUI MySQL tools like MySQL Workbench, Sequel Ace, or PHPMyAdmin, then you can also find timeout-related variables that are configured by these tools in their settings or preferences menu.

For example, in MySQL Workbench for Windows, you can find the timeout-related settings in Edit > Preferences > SQL Editor as shown below:

If you’re using Mac, then the menu should be in MySQLWorkbench > Preferences > SQL Editor as shown below:

If you’re using Sequel Ace like me, then you can find the connection timeout option in the Preferences > Network menu.

Here’s a screenshot from Sequel Ace Network settings:

For other GUI tools, you need to find the option yourself. You can try searching the term [tool name] connection timeout settings in Google to find the option.

And those are the four solutions you can try to fix the MySQL connection lost during query issue.

I hope this tutorial has been helpful for you 🙏

����� 10. Lost connection to MySQL server during query

�� ������ ������� ������ Lost connection to MySQL server �� ������ �� ������� ������� ���������� connect_timeout, �� � �� ���� ������ ������. � ��������� ����� �� ���������� ��� �������.


$php phpconf2009_4.php
string(44) "Lost connection to MySQL server during query"

���� ����� error log ������� ��� ���������:


Version: '5.1.39' socket: '/tmp/mysql_sandbox5139.sock' port: 5139 MySQL Community Server (GPL)
091002 14:56:54 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1

It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338301 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd: 0x69e1b00
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x450890f0 thread_stack 0x40000
/users/ssmirnova/blade12/5.1.39/bin/mysqld(my_print_stacktrace+0x2e)[0x8ac81e]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(handle_segfault+0x322)[0x5df502]
/lib64/libpthread.so.0[0x3429e0dd40]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN6String4copyERKS_+0x16)[0x5d9876]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN14Item_cache_str5storeEP4Item+0xc9)[0x52ddd9]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN26select_singlerow_subselect9send_dataER4ListI4ItemE+0x45)[0x5ca145]
/users/ssmirnova/blade12/5.1.39/bin/mysqld[0x6386d1]
/users/ssmirnova/blade12/5.1.39/bin/mysqld[0x64236a]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN4JOIN4execEv+0x949)[0x658869]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN30subselect_single_select_engine4execEv+0x36c)[0x596f3c]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN14Item_subselect4execEv+0x26)[0x595d96]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN24Item_singlerow_subselect8val_realEv+0xd)[0x595fbd]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN14Arg_comparator18compare_real_fixedEv+0x39)[0x561b89]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN12Item_func_ne7val_intEv+0x23)[0x568fb3]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN4JOIN8optimizeEv+0x12ef)[0x65208f]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0xa0)[0x654850]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z13handle_selectP3THDP6st_lexP13select_resultm+0x16c)[0x65a1cc]
/users/ssmirnova/blade12/5.1.39/bin/mysqld[0x5ecbda]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z21mysql_execute_commandP3THD+0x602)[0x5efdd2]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x357)[0x5f52f7]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xe93)[0x5f6193]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_Z10do_commandP3THD+0xe6)[0x5f6a56]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(handle_one_connection+0x246)[0x5e93f6]
/lib64/libpthread.so.0[0x3429e061b5]
/lib64/libc.so.6(clone+0x6d)[0x34292cd39d]`)
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x6a39e60 = select 1 from `t1` where `c0` <> (select geometrycollectionfromwkb(`c3`) from `t1`)
thd->thread_id=2
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what

�� �����, ��� MySQL ������ ���� �� ������� ��������� ������ 11 ( mysqld got signal 11). �� ���� MySQL ������ �������� � ������������ ������� ������ (��������, ������ � ����� ��� ����������� ������), �� ������� ����� � ����� 11. ��� ������ ���� ����� ���������� Segmentation fault — ����� � ������� � ����������� ������.

������ ������ ������������ ������� �� ������������ � ����� ����������. ���� �� ������ ���� �������, ��� ������ ��� ����� � ����� ������������ ������� ������̣���� �������� ��� ��� ����������� ����� ����������Σ���� ������ ����������� ������� perror, ������� ��������� � ���������� bin ���������� ���� �� ���������� MySQL. ���, ��������, ��� ���������� perror ��� ���� ����������� MacOSX:


$perror 11
OS error code 11: Resource deadlock avoided

����� �� ����� backtrace (������� � Attempting backtrace.) �� ������ � backtace �����.

�ݣ ���� �� ����� ������, ������� ������ ��� ��������:


Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x6a39e60 = select 1 from `t1` where `c0` <> (select geometrycollectionfromwkb(`c3`) from `t1`)

�������� � �������

select 1 from `t1` where `c0` <> (select geometrycollectionfromwkb(`c3`) from `t1`)

���������� ������������� � mysql cli


$./my sql
mysql [localhost] {msandbox} ((none)) > use test
Database changed
mysql [localhost] {msandbox} (test) > select 1 from `t1` where `c0` <> (select geometrycollectionfromwkb(`c3`) from `t1`);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql [localhost] {msandbox} (test) > q
Bye

�� ���� ��� ��������� ������������� ���. ����� �������� ���������� ����� �������, ����� ��� �� ������������ � ���� ����� ���� �� �� ����� ���������.

��� ����� ��������� backtrace


/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN14Item_subselect4execEv+0x26)[0x595d96]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN24Item_singlerow_subselect8val_realEv+0xd)[0x595fbd]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN14Arg_comparator18compare_real_fixedEv+0x39)[0x561b89]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN12Item_func_ne7val_intEv+0x23)[0x568fb3]
/users/ssmirnova/blade12/5.1.39/bin/mysqld(_ZN4JOIN8optimizeEv+0x12ef)[0x65208f]

�� �������� ��������� ������: Item_subselect � Item_singlerow_subselect. ������ ���� �� ���������� � ��� MySQL �� ����� ������� �����, ��� ������� ���������.

��������� ���������� ������


$./my sql
mysql [localhost] {msandbox} (test) > select 1 from `t1` where `c0` <> geometrycollectionfromwkb(`c3`);
Empty set (0.00 sec)

MySQL ������ �������� ���������! �� ����� ������������ ������������ �������� �� ��� ���, ���� ��� �� ����� ���������.

��ɣ� 18: ������ ����������� error log

�� ������ � error log ��� ������ ����������

��� �� ������, �� �� Mac-�


091002 16:49:48 - mysqld got signal 10 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_connections=100
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 225784 K

��� �����, �� backtrace, �� ������� � error log ���. ��� �� ������?

� ���� ������, ��� � ������, ��� ������� general query log. MySQL ������� ����� ������ � general query log � ������ ����� ��������� ���. ������� ������ ������� ������������ ���� ����� ��� ������������� ���������� ��������.


mysql> set global general_log=1;
Query OK, 0 rows affected (0.00 sec)
mysql> set global log_output='table';
Query OK, 0 rows affected (0.00 sec)

��������� ����. ����� ����������� ������� ��������� general query log:


mysql> select argument from mysql.general_log order by event_time desc limit 10;
+--------------------------------------------+
| argument                                   |
+--------------------------------------------+
| Access denied for user 'MySQL_Instance_Manager'@'localhost' (using password: YES)                             |
| select 1 from `t1` where `c0` <>  (select geometrycollectionfromwkb(`c3`) from `t1`) |

������, ��������� ��������, ���������!

��ɣ� 19: ����������� general query log ���� error log �� �������� ���������� � �������� �������� �������.

��� ������������� ����� ��ɣ�� ���������� �����������, ��� ������� mysql.general_log ����� ���������� �� ����� �������� MySQL �������. � ���� ������ ���������� ������ � ����.

����� ���������� �����������, ��� MySQL ������ ���������� �������� �� ����� ������ ������� � general query log. � ����� ������ ����������� ���� ������ ������ ����������, ���� ������.

������, ������� �� ������ ��� �����������, ������ۣ� �� ���� MySQL �������. �� MySQL ������ ����� ���� �������� ���������� � �� ������� �������� �������� � �������.

������, �� ��� ����� �������� �������� ��� RAM

������ �� ��������� ����:


key_buffer_size=235929600
read_buffer_size=4190208
max_used_connections=17
max_connections=2048
threads_connected=13
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 21193712 K
-----
21193712K ~= 20G

�� ���� MySQL ����� ������������ �� 20G RAM! ������ ������ ������, �� ����� ��������� ������������� �� � ��� 20G RAM.

��ɣ� 20: ������ ���������� ���������� �� � ��� RAM ��� ���������� �������.

����� �������� �������� �� �������� ���������� max_connections.

� ���������� ������� max_connections=2048. ��� ���������� �����. ���������, ������ �� � ��� �������� �� ����� ���������� ������������� ����������.

� ��������� � �������� ������, ����� ������������ ������������� �������� max_connections ����������� ������, ��� �� ������� ����� ���������. ��� ��������� � ��������������� ��������� MySQL ������� ��� ����� ��������� ��������� �� ������������� ���-�������.

��ɣ� 21: �������������� �������� max_connections ����� ����� �� ������� ���������.

����� MySQL ������ ����� ���������� �������� ������ ��������. ������ ���������� �� ������ ���������� � error log. ������������ ��� ���������� � ��������� ��������.

������ �� ������ ��� MySQL ������ ������� � �������� ��������. ����� ��� ���������, ��� �� ������ ������ ����������. � ����� ������ ����������� ��������� �������� ��� �����������, ����� ������� ���������.

��ɣ� 22: ����������� �������� ����������� ����� ������������ �������� ����� ���������� ��� ���������� ���������� ���������� ��������, ������� �������� � �������� MySQL �������.

��� �� ����� ����������� ��������� Lost connection to MySQL server ����� ����� ���������� timeout. ���� error log �� �������� ������ ������ ��� �� ������������ ������ ���� ������, �������� ����� log_warnings=2 � ���������������� ���� � ��������� error log ����� ��������� ���������.

��ɣ� 23: ����������� ����� log_warnings=2 ����� ��������� ������� �� � ��� �����Σ���� ����������.

������ ������ ����������� ������ ��� ������������ ��������. ����������� �������������� ���������� ����������� � general log, ����� ������ ����� ������. � �� ���� ����� ��������������� �� ������ ���� ���������, ��������� ��� ���������� ������ � ������� ��������������� �������.

The misstep depicted in the title of this article is entirely outstanding. A couple of attempts on handling the issue exist in various articles on the web. However, in error 2013 you lost connection to MySQL server during a query, concerning this article, there is a specific condition that is exceptionally novel so in the end, it causes the error to occur. The error occurs with the specific error message. That error message is in the going with yield message:


  • root@hostname ~# mysql – uroot – p – h 127.0.0.1 – P 4406
  • Enter secret key:
  • Error 2013 (HY000): Lost relationship with MySQL server at ‘examining initial correspondence bundle’, system error: 0
  • root@hostname ~#

The above error message is a result of partner with a MySQL Database Server. It is a standard MySQL Database Server running on a machine. However, the real connection is a substitute one. The connection exists using Worker holder running collaboration. Coming up next is the reliable running course of that Worker holder:


  • root@hostname ~# netstat – tulpn | grep 4406
  • tcp6 0:4406: * LISTEN 31814/worker-go-between
  • root@hostname ~#

There are at this point lots of articles analyze about this mix-up. For a model in this association in the stack overflow or this association and one more in this association, besides in this association. The general issue is truly something almost identical. There is something misguided in the running arrangement of the regular MySQL Database Server.

Why this happens

This misstep appears when the relationship between your MySQL client and database server times out. Essentially, it took unreasonably long for the request to return data so the connection gets dropped.

By far most of my work incorporates content migrations. These activities for the most part incorporate running complex MySQL requests that burn through a huge lump of the day to wrap up. I’ve found the WordPress wp_postmeta table especially hazardous considering the way that a site with countless posts can without a very remarkable stretch have two or three hundred thousand post meta sections. Joins of enormous datasets from such tables can be especially genuine.

Avoid the issue by sanitizing your requests

Generally speaking, you can avoid the issue absolutely by refining your SQL questions. For example, instead of joining all of the substance of two especially immense tables, have a go at filtering through the records you needn’t waste time with. Where possible, have a go at reducing the amount of partakes in a singular inquiry. This should have the extra benefit of simplifying your inquiry to examine. For my inspirations, I’ve found that denormalizing content into working tables can deal with the read execution. This avoids breaks.

Re-making the inquiries isn’t, by and large, another option so you can effort the going with server-side and client-side workarounds.

A server-side course of action

If you’re ahead for your MySQL server, make a pass at changing a couple of characteristics. The MySQL documentation proposes extending the net_read_timeout or connect timeout values on the server.

The client-side course of action

You can extend your MySQL client’s sever regards on the possibility that you don’t have exclusive induction to the MySQL server.

MySQL Worktable

You can adjust the SQL Editor tendencies in MySQL Work Table:

  • In the application menu, select Edit > Preferences > SQL Editor.
  • Quest for the MySQL Session portion and augmentation the DBMS connection read break regard.
  • Save the settings, very MySQL Work Table, and return the connection.

Step for handling the issue

There are a couple of stages for handling the issue above. There are two segments for handling the issue. The underlying portion is for perceiving the principal driver of the issue. Later on, the ensuing part is the genuine plan taken for tending to the fundamental driver of that issue. Thusly, going with the region which is the underlying portion will focus on power to search for the justification behind the issue.

Glancing through the justification behind the issue

Because of this article, coming up next is the means for settling the mix-up

  1. Check whether the MySQL Database Server measure is truly running. Effect it as follows using any request plan open in the working for truly taking a gander at a running connection. Concerning this article, it is ‘systemctl status MySQL. Thusly, coming up next is a model for the execution of the request plan:

  • root@hostname ~# systemctl status MySQL
  • service – MySQL Community Server
  • Stacked: stacked (/lib/systemd/structure/mysql.service; horrible; vendor preset: engaged)
  • Dynamic: dynamic (running) since Mon 2019-09-16 13:16:12; 40s back
  • Cycle: 14867 ExecStart=/usr/sbin/mysqld – demonize – pid-file=/run/mysqld/mysqld. Pid (code=exited, status=0/SUCCESS)
  • Connection: 14804 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
  • Guideline PID: 14869 (mysqld)
  • Tasks: 31 (limit: 4915)
  • Group:/system. Slice/mysql.service
  • └─14869/usr/sbin/mysqld – daemonize – pid-file=/run/mysqld/mysqld. Pid
  • root@hostname ~#

  1. Preceding partner with MySQL Database Server using a substitute port focusing on any moving toward requesting where it is a worker compartment measure dealing with, basically test the regular connection. By the day’s end, the partner using the normal port tuning in the machine for any moving toward a relationship with MySQL Database Server. Normally, it exists in port ‘3306’. Do it as follow:

  • root@hostname ~# mysql – uroot
  • Goof 2002 (HY000): Can’t interface with neighborhood MySQL server through connection ‘/var/run/mysqld/mysqld. Sock’ (2)
  • root@hostname ~#

The above screw-up message is where the genuine root issue is. Check for the genuine report which is tending to the connection record for MySQL daemon measure as follows:


  • root@hostname ~# disc/var/run/mysqld/
  • root@hostname ~# ls
  • Pid MySQL. sock MySQL. sock. Lock
  • root@hostname ~#

As shown by the above yield, the report doesn’t exist. That is the explanation the relationship with MySQL Database Server is continually failed. Even though the connection cooperation is done through the default port of ‘3306’.

  1. The effort to restart the cooperation and trust that it will handle the issue.

  • root@hostname ~# systemctl stop MySQL
  • root@hostname ~# systemctl start MySQL
  • root@hostname ~# mysql – uroot
  • Slip-up 2002 (HY000): Can’t interface with neighborhood MySQL server through connection ‘/var/run/mysqld/mysqld. Sock’ (2)
  • root@hostname ~#

  1. Unfortunately, the above cycle moreover wraps up in disappointment. Progress forward the movement for handling the issue, just check the MySQL Database arrangement record. In the wake of really investigating the report course of action, it doesn’t fit in any way shape, or form. Eventually, going through hours for changing the arrangement records, nothing happens.

For the reason happens above, check the right game plan before to see which MySQL Database Server arrangement is used by the running MySQL Database Server.

How might we fix MySQL Error 2013 (hy000)?

The fix for MySQL Error 2013 (hy000) depends a ton upon the setting off reason. We should now see how our MySQL Engineers help customers with settling it.

1. Changing MySQL limits

Lately, one of our customers pushed toward us saying that he is getting a mix-up as the one showed underneath while he is efforting to interface with the MySQL server.

Along these lines, our Engineers checked thoroughly and found that the connect timeout regard was set to two or three minutes. Thusly, we extended it to 10 in the MySQL arrangement record. For that, we followed the means underneath:

First thing, we opened the MySQL plan archive at, etc/MySQL/my.cnf

Then, we searched for connect timeout and set it as:

  • connect timeout=10

Then, we had a go at partner with MySQL server and we were viable.

Additionally, it requires the genuine setting of the variable max_allowed_packet in the MySQL arrangement record also. While efforting to restore the landfill record in GB sizes, we increase the value to a higher one.

2. Disabled person Access limits

This slip-up in like manner appears when the host approaches impediments. In such cases, we fix this by adding the client’s IP in, etc/hosts. Allow or license it in the server firewall.

Similarly, the error can happen as a result of the detachment of the server. Lately, in a similar case, the issue was not related to MySQL server or MySQL settings. We did a significant tunnel and found that high association traffic is causing the issue.

Exactly when we checked we found that an unconventional communication running by the Apache customer. Thusly, we killed that, and this good misstep.

3. Growing Server Memory

Last and not least, MySQL memory apportioning furthermore transforms into a basic factor for the slip-up. Here, the server logs will have related segments showing the lacking memory limit.

Subsequently, our Dedicated Engineers decline the innodb_buffer_pool size. This reduces the memory segment on the server and fixes the slip-up.

Checking the MySQL Database Server configuration used by the running MySQL Database Server

In the past fragment or part, there is a need to search for the real plan report used by the running MySQL Database Server. It is essential to guarantee that the plan record used is the right one. Thusly, every change can invite the right impact on dealing with the mix-up issue. Coming up next is the movement for searching for it:

  1. Truly check out the once-over of the assistance first by suggesting the running framework. In the past part, the running framework is the ‘MySQL one. Execute the going with request guide to list the open running cycle:
  • systemctl list-unit-reports | grep MySQL

The yield of the above request plan for a model is in the going with one:


  • user hostname: ~$ systemctl list-unit-archives | grep MySQL
  • service horrendous
  • Service horrendous
  • user hostname: ~$

  1. Then, at that point, truly investigate the substance of the help by executing the going with the request. Pick the right help, in this particular circumstance, it is ‘MySQL. service’:

  • user hostname: ~$ systemctl cat myself. service
  • #/lib/system/structure/Mysql.service
  • # MySQL systemd organization record
  • [Unit]
  • Description=MySQL Community Server
  • After=network. Target
  • [Install]
  • Wanted by=multi-user. Target
  • [Service]
  • Type=forking
  • User=mysql
  • Group=mysql
  • PIDFile=/run/mysqld/mysqld. Pid
  • PermissionsStartOnly=true
  • ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
  • ExecStart=/usr/sbin/mysqld – daemonize – pid-file=/run/mysqld/mysqld. Pid
  • Timeouts=600
  • Restart=on-dissatisfaction
  • Runtime Directory=mysqld
  • RuntimeDirectoryMode=755
  • LimitNOFILE=5000
  • user hostname: ~$

  1. The record obligated for starting the help is in the archive ‘/usr/share/MySQL/MySQL-systems-start’ according to the yield message above. Coming up next is the substance of that record which is only fundamental for it:

  • if [! – r, etc/MySQL/my.cnf]; then,
  • resonation “MySQL arrangement not found at, etc/MySQL/my.in. Assuming no one minds, make one.”
  • leave 1
  • fi
  • …..

  1. Resulting in truly taking a gander at the substance of the report ‘/, etc/MySQL/my.on, obviously, it isn’t the right record. Accordingly, to be more exact, there are other ways to deal with find the planned archive used by the running MySQL Database Server. The reference or the information exists in this association. Hence, according to the information in that association, basically perform the going with request guide to get the right one. It is forgetting the cycle ID and the right MySQL Database Server running collaboration:

  • root@hostname ~# netstat – tulpn | grep 3306
  • tcp6 0:3306: * LISTEN 21192/mysqld
  • root@hostname ~# ps aux | grep 21192
  • root@hostname ~# ps aux | grep 21192
  • mysql 21192 0.2 0.1 3031128 22664? Sl Sep16 1:39/usr/sbin/mysqld – daemonize – pid-file=/run/mysqld/mysqld. Pid
  • root 25442 0.0 23960 1068 pts/20 S+ 01:41 0:00 grep 21192
  • root@hostname ~#
  • Ensuing to getting the right running cycle, do the going with the request of ‘trace file_name_process’:
  • root@hostname ~# album/usr/bin/
  • root@hostname ~# strace. /mysqld
  • Coming up next is fundamental for the yield of the request:
  • detail, etc/my.cnf”, 0x7fff2e917880) = – 1 ENOENT (No such archive or vault)
  • detail, etc/mysql/my.cnf”, {st_mode=S_IFREG|0644, st_size=839, …}) = 0
  • openat (AT_FDCWD, “/, etc/mysql/my.cnf”, O_RDONLY) = 3
  • fstat (3, {st_mode=S_IFREG|0644, st_size=839, …}) = 0
  • brk(0x35f6000) = 0x35f6000
  • read (3, “#n# The MySQL data base server co”…, 4096) = 839
  • openat (AT_FDCWD, “/, etc/mysql/conf. d/”, O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
  • fstat (4, {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
  • get dents (4, /* 4 entries */, 32768) = 120
  • get dents (4, /* 0 entries */, 32768) = 0
  • close (4) = 0
  • detail, etc/mysql/conf.d/mysql.cnf”, {st_mode=S_IFREG|0644, st_size=629, …}) = 0
  • openat (AT_FDCWD, “/, etc/mysql/conf.d/mysql.cnf”, O_RDONLY) = 4
  • fstat (4, {st_mode=S_IFREG|0644, st_size=629, …}) = 0
  • read (4, “[mysqld]nn# Connection and Three”…, 4096) = 629
  • read (4, “”, 4096) = 0
  • close (4) = 0
  • detail, etc/mysql/conf.d/mysqldump.cnf”, {st_mode=S_IFREG|0644, st_size=55, …}) = 0
  • openat (AT_FDCWD, “/, etc/mysql/conf.d/mysqldump.cnf”, O_RDONLY) = 4
  • fstat (4, {st_mode=S_IFREG|0644, st_size=55, …}) = 0
  • read (4, “[MySQL dump] nquicknquote-namesnma”…, 4096) = 55
  • read (4, “”, 4096) = 0
  • close (4) = 0
  • read (3, “”, 4096) = 0
  • close (3) = 0
  • detail (“/root/.my. cnf”, 0x7fff2e917880) = – 1 ENOENT (No such record or list)

The right one is finally in ‘/, etc/MySQL/conf.d/mysql.cf. Resulting in truly investigating the substance of the record, it is an empty archive. This is its essential driver. There has been some update and inverse present type of the MySQL Database Server, it making some disaster area the MySQL Database Server. The plan is essentially to fill that empty plan record with the right arrangement. The reference for the right arrangement of MySQL Database Server exists in this association. Restart the MySQL Server again, the above error issue will be tended to.

on September 10, 2019 •

In this blog post, I will show you how to troubleshoot and resolve connectivity issues with Aurora MySQL RDS Instance.

Problem Statement 

We were unable to establish connection with one of our Aurora MySQL RDS data store. I use MySQL Workbench locally to connect to the AWS databases and I was able to connect to every other database except this one. Please find below the error details —

Lost connection to MySQL server during query

Failed to connect

Please:
1 Check that MySQL is running on address *****
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the user admin has rights to connect to ***** from your address (MySQL rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for ***** connecting from the host address you’re connecting from.

Reading through the above seems like there is a connection issue between the MySQL client and the Database server and the connection timed out before returning data.

Is the issue specific to MySQL Workbench?

  • Open the MySQL Workbench Preferences.
  • Check if the SSH Timeout and DBMS Timeout value is set to only a few seconds.
  • Try to increase the default value of the connection timeouts.
  • Save the settings, close the MySQL Workbench and reopen the connection to see if you are able to connect to the database.

Workbench Preferences

DBMS Timeout

Did you try rebooting the Database instance?

Rebooting a DB instance restarts the database engine service. It will result in a momentary outage though.

Reboot Database

You can also reboot the database instance using AWS CLI —

aws rds reboot-db-instance –db-instance-identifier databasename –profile live –region us-east-1

Make sure to check the Database status and confirm it is ‘Available’

Database Status

Did you check the Cloudwatch Metrics for the Database Cluster?

You can check the database Cloudwatch metrics – especially DatabaseConnections, EngineUptime and UpdateThroughput as a troubleshooting step.

                       
          
                       

In this case seems like after an engine restart on 8/11, there has been some connectivity issues.

Did you check the Database Error Logs?

You can view, download, and watch database logs using the Amazon RDS console.

RDS Error Logs

This is where I was able to figure out the root cause of the connectivity failure. Evidently there was an error in the logs stating – ‘init_connect command failed’

Init Connect Command Failed

Init_connect — This parameter defines a string for the server to run for each client that connects. There is no default value for this parameter. The string consists of one or more SQL statements, separated by semicolons.

init_connect

I had an incorrect value mentioned  the ‘init_connect’ parameter which caused the issue. Once I corrected the value and applied the changes, I was able to connect to the database.

Conclusion 

Summarizing this blog post, there are a number of things you can do to troubleshoot connectivity issues with your AWS RDS database while trying to connect locally via MySQL Workbench —

  1. Confirm the issue is not specific to MySQL Workbench
  2. Reboot the Database instance
  3. Check the Cloudwatch Metrics for the Database Cluster
  4. Check the Database Error Logs

Check out my other recent blog posts around troubleshooting issues —

Troubleshooting Issues with AWS Database Migration Service

Flyway Error: Found non-empty schema(s) without schema history table

Tomcat Error – java.net.BindException: Address already in use

Resolving Gradle issues in IntelliJ IDEA

Synchronize Gradle projects with workspace failed


Categories: AWS, MySQL

Tags: AWS, MySQL

Понравилась статья? Поделить с друзьями:
  • Lost connection to altserver как исправить ошибку
  • Lost connection terraria steam как исправить
  • Lost connection internal server error
  • Lost ark ошибка g0x9 spelpwp1p2nt
  • Lost ark как изменить управление мышкой