Framework: Connect mysql 8 MySQL server has gone away

Created on 31 Aug 2018  路  7Comments  路  Source: laravel/framework

  • Laravel Version: 5.6.35
  • PHP Version: 7.1.16
  • Database Driver & Version: mysql 8.0.12

Description:

throw error SQLSTATE[HY000] [2006] MySQL server has gone away

view mysql status:
mysql> show variables like '%timeout%';

+-----------------------------------+----------+
| 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 | 604800 |
| 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 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 604800 |
+-----------------------------------+----------+

Steps To Reproduce:

Most helpful comment

@fatrbaby I know it's been a while but I've found the answer. Use the following command to update your password with new authentication plugin. You can use MySQL 8 now. Have fun.

ALTER USER `username`@`localhost` IDENTIFIED WITH caching_sha2_password BY 'password';

OR

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

All 7 comments

Ive got this problem once, and it appeared to be a configuration issue on the side of mysql.
Most of the times this error message has two main causes and solutions:

  • Server timed out and closed the connection, but what i see from the config the wait_timeout should be high enough.
  • Server dropped an incorrect or too large packet, how large is the query result? did you already try to increase the value of max_allowed_packet ?

@bolivir Thx for your answer銆侷 am execute a very simple SQL only and the value of the max_allowed_packet is 67108864, so i think is not about of this setting銆俆his problem is on MySQL version 8 only锛宎nd I never had a problem when I used mysql7.

It seems that you must set set higher values for both wait_timeout and interactive_timeout. I couldn`t reproduce it locally, and I am running Laravel+MySQL8 since the MySQL 8 GA release, but I found this stackoverflow link with further details:

https://stackoverflow.com/a/33250885

I haven't found any errors in two days. I can only use 5.7. Thank you for all help.

@fatrbaby I know it's been a while but I've found the answer. Use the following command to update your password with new authentication plugin. You can use MySQL 8 now. Have fun.

ALTER USER `username`@`localhost` IDENTIFIED WITH caching_sha2_password BY 'password';

OR

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Thank You. it`s owrking for me

thanks

Was this page helpful?
0 / 5 - 0 ratings