[英]Doctrine\DBAL\Driver\PDOException SQLSTATE[HY000] [2006] MySQL server has gone away
I have a Laravel 6.2 application and so far it is a basic application almost out of the box.我有一个 Laravel 6.2 应用程序,到目前为止它是一个几乎开箱即用的基本应用程序。 I used Laravels out of the box auth scaffolding and created a user and am able to see this user in my db (mysql workbench).我使用 Laravel 开箱即用的身份验证脚手架并创建了一个用户,并且能够在我的数据库(mysql 工作台)中看到该用户。 The user is created but then I use the php artisan serve
command then try to sign in as the user I just created the browser hangs for about 1 minute then spits out the following error:用户已创建,但随后我使用php artisan serve
命令然后尝试以我刚创建的用户身份登录,浏览器挂起约 1 分钟,然后吐出以下错误:
Doctrine\DBAL\Driver\PDOException
SQLSTATE[HY000] [2006] MySQL server has gone away
I have researched other posts relating to this command and checked my mysql timeout and I increased the limits and it still outputs this error.我研究了与此命令相关的其他帖子并检查了我的 mysql 超时,我增加了限制,但它仍然输出此错误。 What could be the issue?可能是什么问题? I am including output from mysql so you can all see.我包括了 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 | 31536000 |
| 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 | 31536000 |
+-----------------------------------+----------+
SHOW STATUS WHERE variable_name = 'Threads_connected';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 2 |
+-------------------+-------+
SHOW STATUS WHERE variable_name LIKE 'Connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 24 |
+---------------+-------+
Mysql Version mysql版本
mysql --version
mysql Ver 8.0.18-0ubuntu0.19.10.1 for Linux on x86_64 ((Ubuntu))
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.060 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.058 ms
The php.net manual has an explanation: php.net手册有解释:
When running a PHP version before 7.1.16, or PHP 7.2 before 7.2.4, set MySQL 8 Server's default password plugin to mysql_native_password or else you will see errors similar to The server requested authentication method unknown to the client [caching_sha2_password] even when caching_sha2_password is not used.当运行 7.1.16 之前的 PHP 版本或 7.2.4 之前的 PHP 7.2 时,将 MySQL 8 Server 的默认密码插件设置为 mysql_native_password 否则您将看到类似于 The server requests authentication method unknown to the client [caching_sha2_password] 的错误,即使在 caching_sha2_password 时未使用。
This is because MySQL 8 defaults to caching_sha2_password, a plugin that is not recognized by the older PHP (mysqlnd) releases.这是因为 MySQL 8 默认使用 caching_sha2_password,这是旧 PHP (mysqlnd) 版本无法识别的插件。 Instead, change it by setting default_authentication_plugin=mysql_native_password in my.cnf.相反,通过在 my.cnf 中设置 default_authentication_plugin=mysql_native_password 来更改它。 The caching_sha2_password plugin will be supported in a future PHP release.未来的 PHP 版本将支持 caching_sha2_password 插件。 In the meantime, the mysql_xdevapi extension does support it.同时, mysql_xdevapi扩展确实支持它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.