如何在使用 Workbench 时添加 mysqldump 配置标志?

huangapple go评论68阅读模式
英文:

How to add mysqldump config flags while using Workbench?

问题

我正试图导出一个受SSH密钥和私有网络保护的数据库,这意味着我无法登录到主机本身来在本地运行mysqldump,而且某种原因,ssh -i "key" 对我来说也无法远程运行它。

我唯一能看到的选项是通过Workbench连接并从那里导出,但当我尝试导出时,出现了PROCESS权限错误。根据我的研究,可以通过在mysqldump.exe上使用--no-tablespaces标志来绕过它,因此我正在寻找一种方法来添加它,以便Workbench会使用该标志调用mysqldump.exe。

我发现MySQL可以读取配置文件my.cnf和my.ini,但我不知道要在其中写什么以获得--no-tablespaces的替代方法。

英文:

I am trying to export a database which is protected by a SSH key and a private network, meaning I can't login to the host itself to run mysqldump locally and somehow the ssh -i "key" doesn't work for me to run it remotely too.

The only option I see is to connect via Workbench and dumpt it from there, but when I try to dump, I get a PROCESS privelage error. As I researched it can be circumvented by using a --no-tablespaces flag on mysqldump.exe, so I am looking for a way to add it so that Workbench would call mysqldump.exe with that flag.

I found that MySQL can read configuration files my.cnf and my.ini, but I don't know what to write in them for a --no-tablespaces alternative.

答案1

得分: 2

"MySQL Programs / Using MySQL Programs / Specifying Program Options / Using Option Files"页面包括:

> 大多数MySQL程序可以从选项文件(有时称为配置文件)中读取启动选项。选项文件提供了一种方便的方式来指定常用选项,以便您不必每次运行程序时都在命令行中输入它们。
>
> 要确定程序是否读取选项文件,请使用--help选项调用它。(对于mysqld,使用--verbose--help。)如果程序读取选项文件,帮助消息会指示它查找哪些文件以及它识别哪些选项组。

syntax section中,您可以看到一个[mysqldump]标头。

所以,请检查是否将标头+选项添加到您的my.cnfmy.ini中足够:

[mysqldump]
no-tablespaces

> 它抱怨我需要重新加载权限,我找不到任何绕过的方法,我无法访问授予权限。

如果您没有必要的权限并且无法将它们授予您的用户,那么您在所能做的事情上有一定限制。但是,您可以尝试以不需要的权限的方式导出数据库。

一种方法是使用mysqldump命令行实用程序,但有选择地转储数据库的数据和结构,而不尝试转储需要较高权限的任何其他信息。

例如:

mysqldump -u yourUsername -p --no-tablespaces --skip-triggers --routines --events --compact yourDatabaseName > yourDatabaseName.sql

请注意,通过使用这些选项,您可能无法获得数据库的完全保真的转储(例如,它可能不包括触发器)。

如果您绝对必须使用MySQL Workbench并且在权限方面遇到问题,您可能需要联系数据库管理员以授予您所需的权限,或要求他们为您执行转储操作。

英文:

The "MySQL Programs / Using MySQL Programs / Specifying Program Options / Using Option Files" page includes:

> Most MySQL programs can read startup options from option files (sometimes called configuration files). Option files provide a convenient way to specify commonly used options so that they need not be entered on the command line each time you run a program.
>
> To determine whether a program reads option files, invoke it with the --help option. (For mysqld, use --verbose and --help.) If the program reads option files, the help message indicates which files it looks for and which option groups it recognizes.

In the syntax section, you can see a [mysqldump] header.

So check if adding the header+option to your my.cnf or my.ini would be enough:

[mysqldump]
no-tablespaces

> It complained that I need Reload permission which I couldn't find any way to get around, I don't have access to grant any privileges.

If you do not have the necessary privileges and cannot grant them to your user, you are a bit limited in what you can do. However, you can try exporting the database in a different manner that does not require the privileges you lack.

One approach is to use the mysqldump command-line utility, but selectively dump the data and structure of the database without trying to dump any additional information that requires higher privileges.

For example:

mysqldump -u yourUsername -p --no-tablespaces --skip-triggers --routines --events --compact yourDatabaseName > yourDatabaseName.sql

Be aware that by using these options, you might not get a full-fidelity dump of your database (e.g., it might not include triggers).

If you absolutely must use MySQL Workbench and are facing issues with privileges, you might need to contact the database administrator to grant you the required privileges or ask them to perform the dump for you.

答案2

得分: 0

放弃工作台(因为它似乎妨碍了)。

  • 从命令行提示符中,直接使用mysqldump

  • 尝试从其他机器使用SSL(使用适当的标志来反向方向)。如果两个方向都不起作用,请详细说明提供的投诉是什么。

  • MySQL的版本是多少?

> mysqldump至少需要对被导出表的SELECT权限,对被导出视图的SHOW VIEW权限,对被导出触发器的TRIGGER权限,如果未使用--single-transaction选项,则需要LOCK TABLES权限,如果未使用--no-tablespaces选项,则需要PROCESS权限(从MySQL 8.0.21开始),如果gtid_mode=ON且--set-gtid=purged=ON|AUTO,则需要RELOAD或FLUSH_TABLES权限(从MySQL 8.0.32开始)。

英文:

Abandon Workbench (since it seems to be in the way).

  • From a commandline prompt, use mysqldump directly.

  • Try ssl from the other machine (with the suitable flag to reverse the direction). If neither direction works, elaborate on what complaint it provides.

  • What version of MySQL?

> mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the --single-transaction option is not used, PROCESS (as of MySQL 8.0.21) if the --no-tablespaces option is not used, and (as of MySQL 8.0.32) the RELOAD or FLUSH_TABLES priviledge with --single-transaction if both gtid_mode=ON and --set-gtid=purged=ON|AUTO.

huangapple
  • 本文由 发表于 2023年6月26日 21:26:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定