2

I' m using Symfony 4 and Mysql version is 8.0.11 and using a user instead of a root login and when i try to use the command php bin/console make:migration i get this error:

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  

Then i tried to search online and i found out that something went wrong with the MySQL variables wait_timeout and max_allowed_packet and had to change those variables on the file /etc/mysql/my.cnf, the problem is when i go edit that file i only find this:

# 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/

so then i tried to see a thread called "Why is /etc/mysql/my.cnf EMPTY?" and a user said to use one of these paths:

/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/
/etc/mysql/mysql.conf.d/mysqld.cnf

and so i tried... /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]

in the file /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

and in the file /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

and in any of these files i failed to find the MySQL variables wait_timeout and max_allowed_packet, so thanks in advance if someone could help me with this problem. :)

P.S:(i already runned this command php bin/console make:migration several times before this error and also created databases and went fine so its seems to not be an installation problem).

Update: it seems successfully changed the two variables wait_timeout and max_allowed_packet globally by adding to the three files the following

max_allowed_packet=1024M 
wait_timeout=3000000

and then using this command sudo service mysql restart
giving me this:

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)

but still when i tried using this command php bin/console make:migration it gave me the same error has mentioned above this post, also tried to change the wait_timeout variable to 300 by the same method and it gave me the same result. :(

using this command sudo vim /var/log/mysql/error.log i get this:

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.

Update: I've desintalled mysql and php and changed to mysql 5.7 and php 7.2.7, the php change might have solve it acording to link the user @jibe, if someone can't still solve the problem i let these two other links link 1 and link2.

2
  • did you ever figure out what was causing the "Unexpected server respose while doing caching_sha2" message? I got this today with PHP 7.2.8 and 8.0.12. Thanks.
    – ScottyB
    Aug 2 '18 at 5:09
  • I uninstalled version mySQL version 8 and installed 5.7 and the problem got solved,but i have these links that i came across on other platforms:https://dev.mysql.com/doc/refman/8.0/en/gone-away.html GeniusesOfSymfony/WebSocketBundle#299, i hope they help you out. Aug 5 '18 at 17:40
1

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';
1
  • Thanks for reply :D, i m still using MySQL 5.7 and i had no more problems ever since but if i use MySQL 8 i 'll try your solution. Oct 9 '18 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.