MySQL 是否可以在 macOS 上只安装 mysqldump

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47380458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:51:01  来源:igfitidea点击:

Is it possible to install only mysqldump on macOS

mysqlmacosdocker

提问by D.R.

Is it possible to install only mysqldump on macOS without MySQL itself.

是否可以在 macOS 上只安装 mysqldump 而没有 MySQL 本身。

I'm using MySQL db via Docker, but can't dump the DB from my local machine via MySQL Workbench.

我通过 Docker 使用 MySQL 数据库,但无法通过 MySQL Workbench 从我的本地机器转储数据库。

/Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump is version 5.7.17, but the MySQL Server to be dumped has version 5.7.20.

/Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump 是 5.7.17 版本,但是要转储的 MySQL Server 是 5.7.20 版本。

Do you have any suggestions on how to fix that and be able to make dumps from my local machine.

你对如何解决这个问题有什么建议,并且能够从我的本地机器上进行转储。

采纳答案by Bill Karwin

On Linux, you should be able to install the mysql-client package (which includes mysqldump, mysql, mysqladmin, etc.) without the mysql-server. You'd have to install the mysql-shared package too.

在 Linux 上,您应该能够在没有 mysql-server 的情况下安装 mysql-client 包(包括 mysqldump、mysql、mysqladmin 等)。您也必须安装 mysql-shared 包。

But I don't know of a package for MacOS that has these packages split up. The binary distribution for MacOS has everything.

但我不知道有哪些 MacOS 包将这些包分开了。MacOS 的二进制发行版拥有一切。

You could install the MySQL package for MacOS and just ignore the fact that you have a mysqld instance. Or you could stop the instance and configure it not to start automatically at bootup (the MacOS distribution includes a System Preferences applet for MySQL, where you can configure it).

您可以为 MacOS 安装 MySQL 包,而忽略您拥有 mysqld 实例这一事实。或者,您可以停止实例并将其配置为在启动时不自动启动(MacOS 发行版包括用于 MySQL 的系统首选项小程序,您可以在其中配置它)。

If you want just the client on MacOS, you'd probably have to download the source and build it yourself. I think that's more trouble than it's worth. It would require installing Xcode, and figuring out how to build the client only, etc. This work would likely take hours.

如果您只想要 MacOS 上的客户端,则可能必须下载源代码并自行构建。我认为这比它的价值更麻烦。它需要安装 Xcode,并弄清楚如何仅构建客户端等。这项工作可能需要几个小时。

I'd just install the MacOS distribution and be done with the task.

我只是安装了 MacOS 发行版并完成了任务。

回答by Erik Theoboldt

Brew now also has package mysql-client, so you don't need to install the full mysqlpackage just in order to get tools like mysqldump; It's sufficient to run brew install mysql-client.

Brew 现在也有 package mysql-client,所以你不需要安装完整的mysql包来获得类似的工具mysqldump;运行就足够了brew install mysql-client

You should pay attention on the post-installation notice:

您应该注意安装后的通知:

mysql-client is keg-only, which means it was not symlinked into /usr/local, because conflicts with mysql.

If you need to have mysql-client first in your PATH run:

echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile

mysql-client 是 keg-only,这意味着它没有符号链接到 /usr/local,因为与 mysql 冲突。

如果您需要首先在 PATH 中运行 mysql-client:

echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile

Otherwise, you would need to use binary directly located at /usr/local/opt/mysql-client/bin/mysqldump.

否则,您将需要使用直接位于/usr/local/opt/mysql-client/bin/mysqldump.

回答by Matt

See Eriks answer for the new mysql-client pkg

请参阅 Eriks 对新 mysql-client pkg 的回答



The latest mysql 5.7 can be installed via brew.

最新的 mysql 5.7 可以通过brew.

brew install [email protected]

It takes up about 253MB + 19MB for openssl.

openssl 大约需要 253MB + 19MB。

You can remove the server components and cruft manually to get the size down to 127MB

您可以手动删除服务器组件和 cruft 以将大小减小到 127MB

cd /usr/local/Cellar/mysql/5.7.20/
rm -f bin/mysqld bin/mysqld_* lib/libmysqld.a bin/*_embedded

Brew doesn't allow arbitrary package versions to be installed. Some packages do offer MINOR version installs like [email protected]but you will get the latest from that series.

Brew 不允许安装任意版本的软件包。有些软件包确实提供了 MINOR 版本的安装,[email protected]但您将从该系列中获得最新版本。

If you have previously installed a version though (and haven't run brew cleanup) it can be switched back to with brew switch.

如果您之前安装了一个版本(但尚未运行brew cleanup),则可以将其切换回brew switch.

brew info mysql
brew switch mysql 5.7.20

回答by Karol Murawski

There is another option.

还有另一种选择。

A. Steps:

A. 步骤:

  1. Install MysqlWorkbench
  2. copy mysql/mysqldumpfrom /Applications/MySQLWorkbench.app/Contents/MacOSto preferred place.
  3. Use mysqldump from command line
  1. 安装 MysqlWorkbench
  2. mysql/mysqldump/Applications/MySQLWorkbench.app/Contents/MacOS复制到首选位置。
  3. 从命令行使用 mysqldump

Should also work when you remove MysqlWorkbench.

删除 MysqlWorkbench 时也应该工作。

B. Install XAMPP and replace mysqldump path in workbench https://stackoverflow.com/a/40361525/5380255

B.安装XAMPP并替换workbench中的mysqldump路径https://stackoverflow.com/a/40361525/5380255