130

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?

185

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, such as /etc/my.cnf or ~/.my.cnf.

  • --databases <database name> for a particular database – Mohhamad Hasham Jul 5 '18 at 6:05
  • @forthrin Answer edited to show how to make the change permanent. – Andrew Schulman Aug 15 '18 at 15:04
  • 2
    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. – Alex Barker Dec 26 '18 at 20:40
  • 6
    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 at 17:27
  • 1
    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 at 14:35
29

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.

  • 7
    Only MySQL Workbench version 8.0.13 and after has this option to disable "Use Column Statistics". – Paul Deng Nov 7 '18 at 9:22
  • 7
    MySQL Workbench version 8.0.14 doesn't have this option. Looks like they took it out. – Dean Or Jan 24 at 0:11
  • 3
    Indeed, bugs.mysql.com/bug.php?id=94294, should be back in 8.0.16... – Jean-Christophe Meillaud Mar 12 at 16:53
  • still happen at 8.0.16 – Amir Bar Jun 25 at 10:35
  • 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 at 16:37
20

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

Yes, probably this error is due to versions difference.

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.

  • 3
    For Windows users, this .exe was located at: C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe – Jason Oct 18 '18 at 21:42
  • 1
    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 at 9:15
5

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 $@
  • 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 '18 at 21:19
5

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!

  • 6
    I don't have this option in the "Other" section – JoRouss Feb 2 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 :-) – François Breton Feb 6 at 17:10
  • I ended up using @DodiX suggestion. Thanks @Francois! – JoRouss Feb 8 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 at 22:10
  • @Bostone, this solution doesn't ommit the error. – Casper Mar 25 at 8:30
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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.