Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable column-statistics in MySQL 8 permanently?

Since MySQL 8 the column-statistics flag is enabled by default.

So if you try to dump some tables with MySQL Workbench 8.0.12, you get this error message:

14:50:22 Dumping db (table_name) Running: mysqldump.exe --defaults-file="c:\users\username\appdata\local\temp\tmpvu0mxn.cnf" --user=db_user --host=db_host --protocol=tcp --port=1337 --default-character-set=utf8 --skip-triggers "db_name" "table_name" mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'db_name' AND TABLE_NAME = 'table_name';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

Operation failed with exitcode 2 14:50:24 Export of C:\path\to\my\dump has finished with 1 errors

Is there any way in MySQL (Workbench) 8 to disable column-statistics permanently?


Workaround 1

An annoying workaround is doing it by hand via:

mysqldump --column-statistics=0 --host=... 

Workaround 2

  1. rename mysqldump
  2. create a shell script (or batch on Windows)
  3. call the renamed mysqldump with the --column-statistics=0 argument within this script
  4. save it as mysqldump

Workaround 3

  1. download MySQL 5.7
  2. extract mysqldump
  3. use this mysqldump

For example in MySQL Workbench: Edit / Preferences... / Administration / Path to mysqldump Tool


Thanks in advance!

like image 250
Flo Bayer Avatar asked Jul 31 '18 13:07

Flo Bayer


1 Answers

Workaround for me:

  1. Create file named mysqldump.cmd with contents:
    @echo off     "c:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump.exe" %* --column-statistics=0 

(replace path to mysqldump.exe if necessary)

  1. Open MySQL Workbench and go to Edit > Preferences > Administration, change path to mysqldump tool and point it to mysqldump.cmd
like image 157
user3175253 Avatar answered Oct 02 '22 11:10

user3175253