Fix for mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')...
May 11th, 2023
Warning: This post is 3 years old. Some of this information may be out of date.
Recent updates to the mysqldumpcommand have features specific to MySQL 8. When dumping a schema on anything less than 8.0 you may get the following:
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')
FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'wordpress'
AND TABLE_NAME = 'actions';':
Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
The solution is to add the --column-statistics=0 parameter, e.g:
mysqldump -u root -p wordpress --column-statistics=0 > wordpress_backup.sql