错误信息
使用 MySQL Workbench 导出数据时总是报Unknown table 'column_statistics' in information_schema (1109)
的错误。
下面是我在导出ApolloPortalDB
的Users
表的数据时 MySQL Workbench 的错误提示。
16:50:54 Dumping ApolloPortalDB (Users)
Running: /Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump --defaults-file="/var/xxxx/xxx/xxxx/T/xxx/extraparams.cnf" --user=root --host=localhost --protocol=tcp --port=3306 --default-character-set=utf8 --skip-triggers --no-create-info "ApolloPortalDB" "Users"
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'ApolloPortalDB_V192' AND TABLE_NAME = 'Users';': Unknown table 'column_statistics' in information_schema (1109)
Operation failed with exitcode 2
16:50:55 Export of /Users/uwoerla/dumps/Dump20221222 has finished with 1 errors
这种情况一般是 MySQL8.0+ 高版本的 mysqldump 命令去访问低版本的 MySQL 实例时发生。
这个如何解决呢?
临时解决办法
找到Data Export
功能交互流程中的Advanced Options
设置入口
点击Advanced Options
按钮。
在打开的界面中找到 column-statistics - Writing ANALYZE TABLE statements to generate statistics historams (set 0 to diasble).
这个设置项把它的值由TRUE
修改为0
即可。
修改前
修改后
这样你就可以愉快的导出数据了。
永久解决办法
但是
凡事都有但是,这种方法当你重启MySQL Workbench
的时候上面设置的column-statistics
参数又回到了原样,它的值又变回了TRUE
。
有没有什么办法能一劳永逸呢?
当然有了,在你进行Data Export
功能交互流程中一般会有一个提示
看到标题中的mysqldump Version Mismatch
你就应大概知道怎么回事儿了。
再看看内容
/Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump is version 8.0.13, but the MySQL Server to be dumped has version 5.7.30.
Because the version of mysqldump is not the same as the server, some features may not be backed up properly.
It is recommended you upgrade or downgrade your local MySQL client programs, including mysqldump, to a version equal to or newer than that of the target server.
The path to the dump tool must then be set in Preferences -> Administrator -> Path to mysqldump Tool:
客户端的mysqldump
的版本是 8.0.13 ,服务端的版本是 5.7.30,让我们去Preferences -> Administrator -> Path to mysqldump Tool
这个路径去设置客户端的mysqldump
。
默认情况下,这里并没有设置。
根据自己的情况安装对应版本的mysqldump
然后去设置即可。
这样即使你重启MySQL Workbench
依然可以流畅的使用Data Export
的功能。