framework: php artisan schema:dump error (mysqldump8 and mysqld 5.7)

  • Laravel Version: 8.0.0
  • PHP Version: 7.4.*
  • Database Driver & Version: mysqldump 8 and mysqld 5.7

Description:

executing :

php artisan schema:dump

I receive an error

mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'db_laravel_8' AND TABLE_NAME = 'failed_jobs';': Unknown table 'column_statistics' in information_schema (1109)

due to the different version mysqldump 8 against an older mysql daemon 5.7. schema:dump execute mysqldump local command. The version 8 has the flag column-statistics set as 1 (true) by default. mysql5.7 could not have “information_schema.COLUMN_STATISTICS”.

Steps To Reproduce:

In a envirnoment where you have mysqldump 8 and mysql5.7 execute php artisan schema:dump

Fix

  • In baseDumpCommand() (MySqlSchemaState.php) add option column-statistic=0
    protected function baseDumpCommand()
    {
        $gtidPurged = $this->connection->isMaria() ? '' : '--set-gtid-purged=OFF';
        $statisticOff = " --column-statistics=0 ";
        return 'mysqldump ' . $statisticOff . ''.$gtidPurged.' --skip-add-drop-table --skip-add-locks --skip-comments --skip-set-charset --tz-utc --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --user=$LARAVEL_LOAD_USER --password=$LARAVEL_LOAD_PASSWORD $LARAVEL_LOAD_DATABASE';
    }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (24 by maintainers)

Most upvoted comments

I know this is closed but my solution on ubuntu 20.04 was to do the following :

apt remove mysql-client
apt install mariadb-client

Make sure you use the client made for your mysql server type.

Do you want to PR your fix?