Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backups failing: need to write MySQL unixSocket config to temp my.cnf #2794

juddlyon opened this issue Apr 23, 2018 · 0 comments


None yet
2 participants
Copy link

commented Apr 23, 2018


The _createDumpConfigFile method in /vendor/craftcms/cms/src/db/mysql/Schema.php does not include the unixSocket setting when creating the temporary config file passed to mysqldump via the --defaults-extra-file flag.

When using a non-default socket path this will trigger the following error:

...failed with exit code 2: mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I realize there is a backupCommand General Config override, but it feels like if you designate the unixSocket in db.php it should be respected here. The temp file seems to take precedence over my [mysqldump] config so my backups fail.

Here's my quick fix.

$unixSocket = $dbConfig->unixSocket ? 'socket='.$dbConfig->unixSocket : '';
$contents = '[client]'.PHP_EOL.

Steps to reproduce

  1. Use a non-default unix socket location for MySQL
  2. Trigger a backup
  3. Check /storage/logs/web.log for the mysqldump error

Additional info

  • Craft version: Craft CMS 3.0.2
  • PHP version: PHP 7.1.12
  • Database driver & version: MySQL 5.6.38
    I'm using the AWS Lightsail Bitnami Nginx 1.12.2-3 AMI where everything is mapped to /opt/bitnami/

@angrybrad angrybrad self-assigned this Apr 24, 2018

@angrybrad angrybrad closed this in 68a29d0 May 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.