503

Every time I try to make a mysqldump I get the following error:

$> mysqldump --single-transaction --host host -u user -p db > db.sql
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM,
'$."number-of-buckets-specified"') FROM
information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'db' AND
TABLE_NAME = 'Absence';':
Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

The result is a dump which is not complete. The strange thing is that the same command, executed from another host, works without throwing any errors. Did someone experienced the same problem?

I'm using mysql-client 8.0 and try to access a mysql 5-7 server - maybe that is the reason?

23 Answers 23

820

This is due to a new flag that is enabled by default in mysqldump 8. You can disable it by adding --column-statistics=0. The command will be something like:

mysqldump --column-statistics=0 --host=<server> --user=<user> --password=<password> 

Check this link for more information. To disable column statistics by default, you can add

[mysqldump]
column-statistics=0

to a MySQL config file, go to /etc/my.cnf, ~/.my.cnf, or directly to /etc/mysql/mysql.cnf.

9
  • 3
    @forthrin Answer edited to show how to make the change permanent. Aug 15, 2018 at 15:04
  • 3
    There is also a setting in MySQL Workbench: Under "Advanced Options...", in the "other" section, there is a column-statistics that is set to "TRUE". Change this to zero as suggest to disable. Dec 26, 2018 at 20:40
  • 9
    MySQLWorkbench v8.0.14 does not have that setting. What I did (on a Mac) was download an older version of MySQLWorkbench, opened up that package (Show Package contents) and pulled out its bundled version of 'mysqldump'. I then edited MySQLWorkbench preferences to look at this version of 'mysqldump' instead of its own. Export works just fine without having to set any flags. ref) bugs.mysql.com/bug.php?id=91640#c484427
    – Scott
    Jan 22, 2019 at 17:27
  • 10
    For anyone using DataGrip, you can right-click on the schema in the Database window, go to "Dump with 'mysqldump'", and add the --column-statistics=0 argument to the generated argument list in the box at the bottom of the popup window.
    – Travesty3
    May 1, 2019 at 14:35
  • 1
    Interestingly, the link you proved above explicitly states: "This option is disabled by default..."
    – M Klein
    Jan 25, 2021 at 15:27
48

For those using MySQL Workbench, there is an "Advanced Options" button on the Data Export screen. The option "Use Column Statistics" can be disabled by setting to 0.

I have not confirmed, but the following information has been suggested to also be true: In Version 8.0.14 it's missing. In Version 8.0.16 it's doing this by default.

15
  • 9
    Only MySQL Workbench version 8.0.13 and after has this option to disable "Use Column Statistics".
    – Paul Deng
    Nov 7, 2018 at 9:22
  • 9
    MySQL Workbench version 8.0.14 doesn't have this option. Looks like they took it out.
    – Dean Or
    Jan 24, 2019 at 0:11
  • 4
    I can confirm that MySQLWorkbench v8.0.17 fixed the issue (MacOs). It was throwing this error on MySQLWorkbench v8.0.12 and upgraded. I noticed it didn't warn me about exporting data from a 5.X DB anymore and automatically appended the --column-statistics=0 in the export command.
    – Elte156
    Sep 3, 2019 at 16:37
  • 4
    I am using v8.0.18 and can't find that option either
    – mFeinstein
    Nov 8, 2019 at 19:13
  • 4
    8.0.22 this option is missing. Having problem with MariaDB.
    – ACV
    Jan 3, 2021 at 2:08
30

I spent the whole day looking for a solution, and signed up here just to share mine.

Yes, this error is due to version differences.

Just download the MySQL 5.7 ZIP Archive from here: https://dev.mysql.com/downloads/mysql/ and unzip it, then use the mysqldump.exe file from there.

If you are using MySQL Workbench, you will need to set a path to the mysqldump Tool you downloaded by going to Edit -> Preferences -> Administration (from left hand pane).

Hope this helps.

5
  • 3
    For Windows users, this .exe was located at: C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe
    – Jason
    Oct 18, 2018 at 21:42
  • 2
    MySQLWorkbench v8.0.16 is still missing the option to set the column-statistics flag. This solution is arguably the best answer as it allows proper matching of MySQL versions in case of future issues.
    – Kiksy
    Apr 25, 2019 at 9:15
  • 1
    I tried your solution with mysql-5.7.28-macos10.14-x86_64. It showed "Workbench was unable to get mysqldump version. Please verify the log for more information." Apr 9, 2020 at 16:46
  • For MySQL Workbench CE 8.0.19 on Windows, the path is: C:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump.exe Apr 14, 2020 at 20:37
  • MySQL workbench 8.0.28 is also missing this option so @DodiX 's suggestion is what worked for me. I already had wampserver installed so I just pointed the MySQL Workbench preferences to use the Wampserver's mysqldump.exe, in my case this was C:\wamp64\bin\mysql\mysql5.7.31\bin\mysqldump.exe
    – BlessedHIT
    Feb 11, 2022 at 9:05
22

I know that I am late to the party but this was getting me crazy. If you want to use a recent MySQL Workbench (tried with the newest one as of today, MySQL Workbench 8.0.20) you can patch this file:

plugins/wb_admin_export_options.py

in macOS: (/Applications/MySQLWorkbench.app/Contents/Resources/plugins/wb_admin_export_options.py) Replacing this line:

  "column-statistics":["Writing ANALYZE TABLE statements to generate statistics histograms.", "FALSE", "BOOL", ("8.0.2", None)]

with this one:

"column-statistics":["Writing ANALYZE TABLE statements to generate statistics histograms (set 0 to disable).", "1", "INT", (None, None)]

Then remove the .pyo:

rm /Applications/MySQLWorkbench.app/Contents/Resources/plugins/wb_admin_export_options.pyo

Finally, reload Workbench again and in the Data Export page, click on "Advanced options..." and you will see the column-statistics option again (set 0 to disable and click the Return button)

enter image description here

Note: you can download the patched file from this Gist.

8
  • 1
    This patch worked for me. Does anyone know why this happened?
    – Cletrix
    May 19, 2020 at 13:24
  • Worked like a charm on Windows 7. Thanks.
    – JayJay123
    Aug 20, 2020 at 3:40
  • Worked for me as well. The file ist located '/usr/lib/mysql-workbench/modules/wb_admin_export_options.py' on Ubuntu 18.04.
    – Kai
    Mar 1, 2021 at 11:56
  • Works on windows 10 as well!
    – pleasega
    Sep 27, 2021 at 16:20
  • Yes! This is the correct answer for 2022 using version 8.0.28. Better than having to use phpMyAdmin. Thanks.
    – vr_driver
    Apr 21, 2022 at 0:59
8

Easiest Work Around

When using Mysql Workbench 8.0

  • Open the "Data Export" Tab
  • Click Advanced Options enter image description here
  • Under the Other heading, set column statistics to 0 enter image description here
  • Export againenter image description here

Best of luck!

5
  • 13
    I don't have this option in the "Other" section
    – JoRouss
    Feb 2, 2019 at 21:22
  • @JoRouss Download 8.0.13 downloads.mysql.com/archives/workbench maybe .16 version will have it again ! Otherway we use command line :-) Feb 6, 2019 at 17:10
  • I ended up using @DodiX suggestion. Thanks @Francois!
    – JoRouss
    Feb 8, 2019 at 7:05
  • Stupid workaround until 8.0.16 is out: in Advanced options check "force" so the error will be ignored. Of course this will ignore any other error
    – Bostone
    Mar 5, 2019 at 22:10
  • @Bostone, this solution doesn't ommit the error.
    – Casper
    Mar 25, 2019 at 8:30
7

To make this answer easier, you can rename mysqldump, make a shell script in its place and call the renamed mysqldump with the --column-statistics=0 argument. Eg:

Rename mysqldump:

mv /usr/local/bin/mysqldump /usr/local/bin/_mysqldump

Save the following shell script in its place:

#!/bin/sh

_mysqldump --column-statistics=0 $@
3
  • 1
    This is a great suggestion and works in MacOSX with the Mysql Workbench, however you have to include the full path to your real mysqldump executable or it didn't seem to work. I tried ./ but still wouldn't work. Putting in the full path and the Workbench was able to run it with the stats flagged off.
    – Andy D
    Oct 20, 2018 at 21:19
  • 1
    for Windows, you can have the script like this @echo OFF _mysqldump --column-statistics=0 %*
    – Earlee
    Oct 7, 2020 at 7:04
  • This is a great suggestion. I'm using v8.0.30 and somehow they still don't have a column-statistics option. Seemingly it was removed?
    – rachelderp
    Aug 4, 2022 at 3:49
5

In addittion to pierlo https://serverfault.com/a/919403/586669

From within MySQL Workbench there is an option to set the path of the mysqldump executable. (Edit - Preferences - Administration)

So you can create a .cmd (on Windows) or a .sh file (on Linux or mac) as follows:

mysqldump_nostatistics.cmd:

 @ECHO OFF
 "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump.exe" %*  --column-statistics=0

mysqldump_nostatistics.sh:

#!/bin/sh

_mysqldump $@ --column-statistics=0

Note the order of the parameters (it is different from pierlo's) : the dump command executed includes (or may include) a --defaults-file= option, and this has to be the first parameter.

Also The echo off is needed otherwise the workbench is unable to parse the command output correctly.

1
  • Thank you. This is what worked for me with MySql Workbench 8.0.31 and Bitnami WAMP 7.4.33 which uses MariaDB and mysqldump 10.4.27. Two things that didn't work: 1. Pointing MySql Workbench prefs to WAMP's mysqldump. 2. Setting column-statistics=0 in WAMP's my.ini
    – Nick Hope
    Dec 26, 2022 at 7:29
5

I had this problem using the latest mysql workbench (8.0.23) on OSX (11.1) with mariadb. I solved it by selecting the version of mysqldump found in the mariadb package.

/usr/local/mariadb/mariadb-10.1.37-osx10.13-x86_64/bin/mysqldump

2
  • That works. On linux just make sure MariaDB version of mysqldump is in your PATH, or edit the path in Workbench's Preferences -> Administration Mar 15, 2021 at 18:18
  • On Windows I found the file in the mariadb-10.5.5-winx64.zip\mariadb-10.5.5-winx64\bin folder of the ZIP file download Apr 8, 2021 at 19:52
4

I use XAMPP and MySQL Workbench does warn about a version mismatch. I set MySQL Workbench to point to the XAMPP's mysql.exe and mysqldump.exe.

Go to Edit -> Preferences -> Administration and set the path for each.

This works at least for version 8.0.14. So for others you may want to avoid using the bundled version of mysql and mysqldump.

4
  • 1
    Easy and Clean. It works with WampServer too and on Windows.
    – BlackPearl
    Apr 7, 2020 at 5:34
  • and if the path is something like /usr/local/bin/mysqldump which is hidden in Finder, use cmd+shitt+g to open that location
    – CHAN
    May 8, 2020 at 4:07
  • The Xampp version worked great for me too! Aug 24, 2022 at 23:17
  • Using the xampp version will also get rid of the "mysqldump version mismatch" error I was getting. Aug 24, 2022 at 23:24
4

There a couple of answers above here that refer to renaming the mysqldump binary and creating a wrapper script. This is a terrible approach.

The correct method (in bash) is to alias the command in your .bashrc

alias mysqldump="mysqldump --column-statistics=0"
2

To macOS you need the older version (8.0.13) to see the "column-statistics", because I test the version 8.0.14 and 8.0.15 and both not showing the "column-statistics".

So, to adjust the "column-statistics" use the version 8.0.13 https://downloads.mysql.com/archives/get/file/mysql-workbench-community-8.0.13-macos-x86_64.dmg

1

From MySQL Workbench version 8.0.14 you don't have the option to disable column-statistics

You can do that in version 8.0.13

But you have an option to do it by enabling delete-master-logs in version 8.0.22

  • --delete-master-logs has the same effect as the RESET MASTER SQL command.
  • RESET MASTER deletes all binary log files listed in the index file, resets the binary log index file to be empty, and creates a new binary log file. This statement is intended to be used only when the master is started for the first time.
1

For those using DBeaver check the Local Client is set to create the dump. See next images for reference:

Access to local client selection:

Access to local client selection

Local clients available:

Local clients available

1

I faced the same issue with MySQL workbench latest edition, I resolved it using the mysqldump command line

C:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump --column-statistics=0  --user=USERNAME --host=REMOTE_HOST --protocol=tcp --port=3306 --default-character-set=utf8 DATABASE_NAME > c:\temp\dump.sql --password

Replace USERNAME, REMOTE_HOST, DATABASE_NAME with your names.

1

Depending on your situation, you can get rid of mysql and install mariadb instead. This eliminates the new feature that was introduced in mysql 8.

1
  • This helped me, thank you. I working with AWS Aurora and it looks like it more complaint with the MariaDB than with the original MySQL Nov 4, 2022 at 12:39
1

If using a MariaDB backend with MySQL Workbench 8.0.31 CE use need to download the native MariaDB binaries for your system from https://mariadb.com/downloads/community/ and specify them in MySQL Workbench.

For example, if you are on 64-bit Microsoft Windows OS perform the following:

  1. Goto https://mariadb.com/downloads/community/
  2. On the above page, select your Operating System
  3. Community Server --> Verison (latest GA) --> OS (MS Windows 64-bit) and click on download
  4. Run the Install Shield just downloaded, and make sure "MariaDB Server -> Client Programs" is enabled.
  5. Run up MySQL Workbench
  6. Select the menu: Edit -> Preferences...
  7. Select "Administration" in the left hand column
  8. Update "Path to mysqldump Tool:" to be C:\Program Files\MariaDB 10.10\bin\mariadb-dump.exe
  9. Update "Path to mysql Tool:" to be C:\Program Files\MariaDB 10.10\bin\mariadb.exe

No more performance statistic errors or any other divergent issues down the line between MySQL and MariaDB.

This has been posted for future reference.

0

In my situation, I'm using mac-OS. By the way, there was [mysqldump] column-statistics=0 fields in my.cnf file that is placed under the /usr/local/etc directory. Deleting that field fixed the issue. (not: mysql version is 5.7 and installed via homebrew).

0

I also had the same issue, it occurs when I merge multiple data tables to the existing schema from other schema and export merged data to self contained script file. I did try to change the column-statistics=0,but result was following,

C:\xampp\mysql\bin>mysqldump --column-statistics=0 --host=loalhost --user root --passwod
mysqldump: unknown variable 'column-statistics=0'

So I hadn't help. I analyze the MySQL log I found that

2019-01-21 11:31:30 1050 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2019-01-21 11:31:30 4176 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

its complaining about the size of the innodb_buffer_pool_size. I did make it to 24MB. Then it works.

0

On macOS I fixed this by overriding the bundled mysqldump:

  1. Install mariadb, e.g. brew install mariadb
  2. Navigate to MySQLWorkbench > Preferences > Administration
  3. Set the mysqldump path to the one you just installed, e.g. /opt/homebrew/bin/mysqldump

Note: to find the full path to mysqldump, you can run which mysqldump in your terminal.

0

Since i cannot comment the actual answer from user:cristhiank, i'm adding a slight variation of the actual answer. In my case i had to change it in /etc/my.cnf.d/client.cnf and i had to leave it in the [client] section so not adding a [mysqldump] section.

So for me this was working /etc/my.cnf.d/client.cnf

[client]
column-statistics=0
0

In MySQL Workbench 8.0.31 on Advanced Options tab now exists new option "Force", use it to skip errors like mentioned above.

0

For Ansible users use:

mysql_db:
 ...
 dump_extra_args: --column-statistics=0

In my case it ignores ~/.my.cnf and /etc/my.cnf

0

Copy the mysqldump command from the output window, remove the defaults file part, and add --column-statistics=0 with other option

Open a command window in the mysqldump.exe parent folder and run the command manually, piping to a file in my documents folder (you'll get access denied errors if you just try to dump it to same folder).

Example:

C:\Program Files\MySQL\MySQL Workbench 8.0 CE>mysqldump.exe --user=USER--host=127.0.0.1 --protocol=tcp --port=3306 --default-character-set=utf8 --skip-triggers --column-statistics=0 "mantis" > "C:\users\moi\Documents\dumps\mantis.sql"
1
  • This solution was written by @dartacus several years ago. I'm converting it into a formatted answer since it worked for me and was buried underneath a bunch of other comments. Mar 21, 2023 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .