私はSymfony4を使用しており、Mysqlのバージョンは8.0.11で、ルートログインの代わりにユーザーを使用しています。コマンドphp bin/console make:migration
を使用しようとすると、次のエラーが発生します。
In AbstractMySQLDriver.php line 126:
An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away
In PDOConnection.php line 50:
SQLSTATE[HY000] [2006] MySQL server has gone away
In PDOConnection.php line 46:
SQLSTATE[HY000] [2006] MySQL server has gone away
In PDOConnection.php line 46:
PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109
次に、オンラインで検索しようとしましたが、MySQL変数wait_timeout
とmax_allowed_packet
に問題があり、ファイル/etc/mysql/my.cnf
でこれらの変数を変更する必要があることがわかりました。問題は、移動するときです。そのファイルを編集します私はこれだけを見つけます:
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
それで私は「 なぜ/etc/mysql/my.cnfが空なのですか? 」というスレッドを見ようとしました、そしてユーザーはこれらのパスの1つを使うと言いました:
/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/
/etc/mysql/mysql.conf.d/mysqld.cnf
だから私は試しました.../etc/mysql/conf.d/
:
## Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Client configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysql]
ファイル内/etc/mysql/mysql.conf.d/
:
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
およびファイル内/etc/mysql/mysql.conf.d/mysqld.cnf
:
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
そして、これらのファイルのいずれかで、MySQL変数wait_timeout
とmax_allowed_packet
を見つけることができなかったので、誰かがこの問題で私を助けてくれたら、事前に感謝します。 :)
追伸:(私はこのエラーの前にすでにこのコマンドphp bin/console make:migration
を数回実行し、データベースも作成して問題なく動作したので、インストールの問題ではないようです)。
更新:次の3つのファイルを追加することにより、2つの変数wait_timeout
とmax_allowed_packet
をグローバルに正常に変更したようです。
max_allowed_packet=1024M
wait_timeout=3000000
次に、このコマンドを使用しますSudo service mysql restart
これをくれ:
mysql> SHOW global VARIABLES LIKE "wait_timeout";
+---------------+---------+
| Variable_name | Value |
+---------------+---------+
| wait_timeout | 3000000 |
+---------------+---------+
1 row in set (0,00 sec)
mysql> SHOW VARIABLES like 'max_allowed_packet';
+--------------------+------------+
| Variable_name | Value |
+--------------------+------------+
| max_allowed_packet | 1073741824 |
+--------------------+------------+
1 row in set (0,00 sec)
しかし、このコマンドphp bin/console make:migration
を使用しようとすると、この投稿で前述したのと同じエラーが発生し、同じ方法でwait_timeout
変数を300に変更しようとすると、同じ結果が得られました。 :(
このコマンドを使用してSudo vim /var/log/mysql/error.log
私はこれを取得します:
2018-07-29T18:55:18.382164Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 8 user: 'alexandre'.
2018-07-29T18:55:20.288756Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
2018-07-29T18:55:20.642118Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 31833
2018-07-29T18:55:21.704556Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-07-29T18:55:21.720385Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
更新:mysqlとphpをデインストールし、mysql5.7とphp7.2.7に変更しましたが、phpの変更により、 link ユーザー@jibe、誰かがまだ問題を解決できない場合は、これらの他の2つのリンク link 1 および link2 。
久しぶりですが、答えを見つけました。次のコマンドを使用して、新しい認証プラグインでパスワードを更新します。これでMySQL8を使用できます。楽しんで。
ALTER USER `username`@`localhost` IDENTIFIED WITH caching_sha2_password BY 'password';
OR
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';