MySQL server gone away on fresh installation

I’ve reinstalled my Proxmox server, and wanted to re instantiate my ownCloud docker container with a fresh MySQL server. At first I wanted to restore my old installation (that was running on mariadb), but I discovered that even a fresh ownlcoud install on an almost fresh MySQL server (with increased timeout server variables) wouldn’t start.

I’m getting the following the following docker log:

Creating volume folders...
Creating hook folders...
Waiting for MySQL...
wait-for-it: waiting 180 seconds for
wait-for-it: is available after 0 seconds
Removing custom folder...
Linking custom folder...
Removing config folder...
Linking config folder...
Writing config file...
Fixing base perms...
Fixing data perms...
Fixing hook perms...
Installing server database...
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2006] MySQL server has gone away

In Docker, I created a network called “fixnet”, which I specifically use to fix containers to static IPs. However, I don’t think is an issue, as I’ve verified that the docker container can indeed ping to the MySQL container. I’ve also verified that I can indeed use the custom owncloud user account to connect to the server, and manipulate the owncloud schema, by connecting using MySQL Workbench on my desktop machine.

Steps to reproduce

  1. Fresh install mysql:latest of, with empty data volume
  2. MySQL: Create owncloud schema and create custom user with full access on owncloud schema
  3. MySQL: Set several timeout variables 864000 (see them listed below)
  4. Fresh install owncloud:10.0 of, with empty data volume
  5. Docker container crashes out after attempting to create a fresh database on first boot

Expected behaviour

I expected the database tables to be created in the schema, and the installation process to proceed.

Actual behaviour

No tables were created, as the log errors out with “MySQL server has gone away error”

Server configuration

Operating system: Proxmox 6.2-4

Web server: n/a

Database: MySQL 8.0.20 Community Server

PHP version: n/a

ownCloud version: n/a

Updated from an older ownCloud or fresh install: n/a

Where did you install ownCloud from: docker hub

Signing status (ownCloud 9.0 and above): n/a docker configuration

docker run --net fixnet --ip --name mysql \
    --mount type=bind,src=/path-to-nas/mysql/my.cnf,dst=/etc/my.cnf \
    --mount type=bind,src=/path-to-nas/mysql/data,dst=/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=*** -p 3306:3306 -d mysql:latest

The following MySQL variables were changed to 864000 (10 days):

  • mysqlx_connect_timeout
  • mysqlx_interactive_timeout
  • mysqlx_read_timeout
  • mysqlx_wait_timeout
  • mysqlx_write_timeout
  • net_read_timeout
  • net_write_timeout
  • slave_net_timeout
  • wait_timeout docker configuration

export OWNCLOUD_DOMAIN=localhost
export HTTP_PORT=8080

docker run -d \
  --net fixnet \
  --ip \
  --name owncloud \
  -p ${HTTP_PORT}:8080 \
  -e OWNCLOUD_DB_TYPE=mysql \
  -e OWNCLOUD_DB_NAME=owncloud \
  -e OWNCLOUD_DB_USERNAME=owncloud \
  -v /hyperpool/Backup/scripts/owncloud:/mnt/data:rw \

The content of config/config.php:

$CONFIG = array (
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/owncloud/apps',
      'url' => '/apps',
      'writable' => false,
    1 => 
    array (
      'path' => '/var/www/owncloud/custom',
      'url' => '/custom',
      'writable' => true,
  'trusted_domains' => 
  array (
    0 => 'localhost',
  'datadirectory' => '/mnt/data/files',
  'dbtype' => 'mysql',
  'dbhost' => '',
  'dbname' => 'owncloud',
  'dbuser' => 'owncloud',
  'dbpassword' => '***',
  'dbtableprefix' => 'oc_',
  'log_type' => 'owncloud',
  'supportedDatabases' => 
  array (
    0 => 'sqlite',
    1 => 'mysql',
    2 => 'pgsql',
  'upgrade.disable-web' => true,
  'default_language' => 'en',
  'overwrite.cli.url' => 'http://localhost',
  'htaccess.RewriteBase' => '/',
  'logfile' => '/mnt/data/files/owncloud.log',
  'loglevel' => 2,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'passwordsalt' => '***',
  'secret' => '***',
  'version' => '',

Are you using external storage, if yes which one: n/a

Are you using encryption: no

Are you using an external user-backend, if yes which one: n/a

ownCloud log (data/owncloud.log)

{"reqId":"701f1D63b56w2v4OEVgE","level":3,"time":"2020-06-01T11:14:19+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"PDO::__construct(): MySQL server has gone away at \/var\/www\/owncloud\/lib\/composer\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/PDOConnection.php#43"}

As I need a working owncloud server, I installed a mariadb container of version 10.5, in a similar manner as the MySQL docker container. This works fine. I have now also been able to restore my owncloud server backup.

So as far as I can tell, the issue seems to be specific for the MySQL server/docker container.

1 Like