Spatie Laravel Backup 出現 MySQL GTID 問題

在使用 spatie/laravel-backup 工具進行備份時發生異常訊息,原因是 MySQL 啟用了 GTID 的相關設定。

異常訊息

The dump process failed with a none successful exitcode.
Exitcode
========
2: Misuse of shell builtins
Output
======
<no output>
Error Output
============
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'xxxxx' AND TABLE_NAME = 'abnormal_contracts';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

加入額外輸出參數解決問題

我們可以在 config/database.php 中進行設定使用額外的參數

'mysql' => [
   // ....
    'dump' => [
        // ....
        'add_extra_option' => '--set-gtid-purged=OFF'
    ]
]