93

I want to dump my database, even after following correct syntax it thows me following error.

Syntax I used :

mysqldump -uroot -p omnichannel_store_india > omnichannel_store_india.sql

Throws errors :

mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'omnichannel_store_india' AND TABLE_NAME = 'consignment_items';':

Unknown table 'column_statistics' in information_schema (1109)

1

3 Answers 3

219

This is due to a flag column-statistics 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 <securepass> 

To disable column statistics by default, you can add the following in a MySQL config file, such as /etc/my.cnf or ~/.my.cnf.

[mysqldump]
column-statistics=0

It's brilliantly working for me.

More details about column-statistics:

Add ANALYZE TABLE statements to the output to generate histogram statistics for dumped tables when the dump file is reloaded. This option is disabled by default because histogram generation for large tables can take a long time.

Ref: MySQL official documentaion link

3
  • I was getting this error thrown from PhpStorm when using windows mysqldump.exe. If this is you as well, you can apply this solution manually by adding --column-statistics=0 in the window below the "Out Path" since there is no checkbox for column statistics.
    – ffgpga08
    Nov 19, 2021 at 1:26
  • It would be really helpful to say why this happens. I assume it's because you were using an older MySQL server instance (or a MariaDB server instance, as @terry zhang suggests)
    – stephenfin
    Feb 23, 2022 at 12:54
  • 1
    @stephenfin, if I recalled the situation correctly, that could be due to a version mismatch b/w the Mysql client and MySQL server. Feb 24, 2022 at 5:26
11

In my case, we using mariadb-server and mysql-client(8.0). The column-statistics was introduced on mysql-client 8.0. The quick fixed way it that remove the mysql-client and install mariadb-client.

On ubuntu 20.04, the command is:

apt remove mysql-client
apt install mariadb-client
1
  • It definitely was a client issue. I tried this solution on Ubuntu 20.04 LTS and resolved the fault; thanks-
    – F1Linux
    Feb 25, 2022 at 1:39
2

Since i cannot comment the actual answer from user:Amitesh Bharti, 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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