XF\Db\Exception: MySQL statement prepare error [2006]: MySQL server has gone away

canina

Member
Clean server ubuntu 20.04.5 with lamp.
I am installing a xenforo forum and during the installation the following error occurs:

XF\Db\Exception: MySQL statement prepare error [2006]: MySQL server has gone away in src/XF/Db/AbstractStatement.php at line 230 XF\Db\AbstractStatement->getException() in src/XF/Db/Mysqli/Statement.php at line 198 XF\Db\Mysqli\Statement->getException() in src/XF/Db/Mysqli/Statement.php at line 41 XF\Db\Mysqli\Statement->prepare() in src/XF/Db/Mysqli/Statement.php at line 56 XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 96 XF\Db\AbstractAdapter->query() in src/XF/Db/AbstractAdapter.php at line 324 XF\Db\AbstractAdapter->update() in src/XF/Job/Manager.php at line 274 XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 202 XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 153 XF\Job\Manager->runUnique() in src/XF/Install/Controller/AbstractController.php at line 24 XF\Install\Controller\AbstractController->manualJobRunner() in src/XF/Install/Controller/Install.php at line 198 XF\Install\Controller\Install->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 352 XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259 XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115 XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57 XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2483 XF\App->run() in src/XF.php at line 524 XF::runApp() in install/index.php at line 14

The mysql log is:
'/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu). 2023-05-03T17:54:26.376869Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (requested 105111) 2023-05-03T17:54:26.376874Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 4932 (requested 52488) 2023-05-03T17:54:26.910698Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.20.04.2) starting as process 93538 2023-05-03T17:54:26.964886Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2023-05-03T17:54:28.134622Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2023-05-03T17:54:29.140504Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... 2023-05-03T17:54:29.178362Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2023-05-03T17:54:29.348026Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2023-05-03T17:54:29.348573Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2023-05-03T17:54:29.406019Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32-0ubuntu0.20.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu). 2023-05-03T17:54:29.406291Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock 2023-05-03T18:03:49.760918Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (requested 105111) 2023-05-03T18:03:49.760922Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 4932 (requested 52488) 2023-05-03T18:03:50.078617Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.20.04.2) starting as process 93779 2023-05-03T18:03:50.101949Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2023-05-03T18:03:50.781883Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2023-05-03T18:03:51.552947Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... 2023-05-03T18:03:51.573385Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2023-05-03T18:03:51.867742Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2023-05-03T18:03:51.868049Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2023-05-03T18:03:51.916660Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock 2023-05-03T18:03:51.917208Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32-0ubuntu0.20.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu). 2023-05-03T18:03:49.760922Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 4932 (requested 52488) 2023-05-03T18:03:50.078617Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.20.04.2) starting as process 93779 2023-05-03T18:03:50.101949Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2023-05-03T18:03:50.781883Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2023-05-03T18:03:51.552947Z 0 [System] [MY-010229] [Server] Starting XA crash recovery... 2023-05-03T18:03:51.573385Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2023-05-03T18:03:51.867742Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2023-05-03T18:03:51.868049Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2023-05-03T18:03:51.916660Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock 2023-05-03T18:03:51.917208Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32-0ubuntu0.20.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu).


The my.cnf configuration is:

!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/ [mysqld] max_allowed_packet = 16M wait_timeout = 28800 thread_stack = 128K max_connections = 125 table_open_cache = 52488 key_buffer_size = 32M
what could be the problem?
Thanks.
 
Last edited:
Solution
Yeah that's probably not going to work very well unless you turn a whole bunch of things way down. You need to turn down a bunch of MySQL buffers and likely PHP-FPM (assuming it's what you're using) as well.

Basically, get more RAM.
Looks like you are hitting some config limits.

Are you self managed, shared hosting?

I'll move the thread to server support as that is more appropriate - it's going to require some changes.
 
Yeah that's probably not going to work very well unless you turn a whole bunch of things way down. You need to turn down a bunch of MySQL buffers and likely PHP-FPM (assuming it's what you're using) as well.

Basically, get more RAM.
 
Solution
gone away errors are usually because of too low of a wait_timeout setting, but yours is already high at the default setting. i use 600.

i agree with the above comment, you need more power/ram. your phone has more ram than your web server. :X
 
Thanks. I upgraded and it did go away.

I didn't think in this direction since I have previously installed xenforo countless times and it was always on no more than 1Gb ram
 
Top Bottom