简体   繁体   English

问:如何在 Mysql 工作台中将 --set-gtid-purged=OFF 设置为默认导出参数?

[英]Q: How to set --set-gtid-purged=OFF as a default Export parameter in Mysql workbench?

Ive recently been playing with Mysql Workbench and the Export function has one little annoying feature that is not needed (by me of course).我最近一直在玩 Mysql Workbench,而 Export function 有一个不需要的烦人功能(当然是我不需要的)。 The set-gtid-purged function is set to AUTO by default in the GUI and it seems everytime you want to export without this parameter - you have to change it to OFF in Data Exports - Advanced options. set-gtid-purged function 在 GUI 中默认设置为 AUTO,似乎每次您想要导出时不使用此参数 - 您必须在数据导出 - 高级选项中将其更改为 OFF。 To make it worse - the setting is not remembered.更糟的是 - 设置不会被记住。

Wanted to check if anyone has found a way to set it to OFF permanently for every DB/conenction i make?想检查是否有人找到了一种方法来为我所做的每个数据库/连接将其永久设置为 OFF?

I even checked the wb_options.xml file and the feature is set to OFF but this doesn't seem to stop it for some reason.我什至检查了 wb_options.xml 文件,该功能设置为关闭,但由于某种原因这似乎并没有阻止它。

<value type="string" key="wb.admin.export.option:set-gtid-purged">OFF</value>

Thanks.谢谢。

I've found a temporary solution for this on Linux/Ubuntu我在 Linux/Ubuntu 上找到了一个临时解决方案

  1. Open /usr/lib/mysql-workbench/modules/wb_admin_export.py打开/usr/lib/mysql-workbench/modules/wb_admin_export.py
  2. Search for "--set-gtid-purged=OFF"搜索“--set-gtid-purged=OFF”
  3. Delete or comment that line (#) and the if statement above it.删除或注释该行 (#) 及其上方的 if 语句。
  4. Restart MySQL Workbench重启 MySQL 工作台

Using windows, the path to the file will vary and I will update my answer if someone can give it to me.使用 Windows,文件的路径会有所不同,如果有人可以给我,我会更新我的答案。

I want to do exactly what you are looking for but in AWS RDS.我想在 AWS RDS 中完全按照您的要求进行操作。 so for your case what you must do is:所以对于你的情况,你必须做的是:

Solution解决方案

  1. Update config file Update /etc/my.cnf and add更新配置文件 更新/etc/my.cnf并添加

    [mysqldump] set-gtid-purged=OFF [mysqldump] set-gtid-purged=OFF

  2. No need to restart.无需重新启动。 If you dont have access to that .cnf file then update the update directadmin.conf with the following instruction:如果您无权访问该 .cnf 文件,请使用以下说明更新更新 directadmin.conf:

    extra_mysqldump_options=--set-gtid-purged=OFF extra_mysqldump_options=--set-gtid-purged=OFF

  3. Is possible to run the following command in shell to achieve point number 2:可以在 shell 中运行以下命令来实现第 2 点:

    echo "extra_mysqldump_options=--set-gtid-purged=OFF" >> /usr/local/directadmin/conf/directadmin.conf service directadmin restart echo "extra_mysqldump_options=--set-gtid-purged=OFF" >> /usr/local/directadmin/conf/directadmin.conf service directadmin restart

Official and useful references官方和有用的参考

MySQL Dump MySQL 转储

MySQL enable/disable GTID (Global Transaction Ids) MySQL 启用/禁用 GTID(全局事务 ID)

MySQL extra options during DUMP转储期间的 MySQL 额外选项

On a Mac, running Mysql 5.7, I found the following to work:在 Mac 上,运行 Mysql 5.7,我发现以下内容有效:

In Workbench, select:在工作台中,select:

Server -> Data Export -> Advanced Options服务器 -> 数据导出 -> 高级选项

change "set-gtid-purged - Add 'SET @@GLOBAL.GTID_PURGED' to the output."更改“set-gtid-purged - 添加‘SET @@GLOBAL.GTID_PURGED’到 output。” from AUTO to OFF从 AUTO 到 OFF

Then export your data.然后导出您的数据。

The exported SQL files should no longer have the line:导出的 SQL 文件不应再包含以下行:

"SET @@SESSION.SQL_LOG_BIN= 0;" “设置@@SESSION.SQL_LOG_BIN=0;”

and now it imports successfully.现在它导入成功了。

If you are using only mysqldump in Ubuntu Server如果您在 Ubuntu Server 中仅使用 mysqldump

Try append this to etc/mysql/conf.d/mysqldump.cnf尝试将其附加到 etc/mysql/conf.d/mysqldump.cnf

set-gtid-purged=OFF
column-statistics=0

May looks like this:可能看起来像这样:

set-gtid-purged=OFF 和 column-statistics=0 的 mysqldump.cnf 设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM