Is it possible to install only mysqldump on macOS

MysqlMacosDocker

Mysql Problem Overview


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

I'm using MySQL db via Docker, but can't dump the DB from my local machine via 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.

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

Mysql Solutions


Solution 1 - Mysql

Brew now also has package mysql-client, so you don't need to install the full mysql package just in order to get tools like mysqldump; It's sufficient to run 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

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

Solution 2 - Mysql

See Eriks answer for the new mysql-client package: brew install mysql-client


The latest mysql 5.7 can be installed via brew.

brew install mysql@5.7

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

You can remove the server components and cruft manually to get the size down to 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.

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

brew info mysql
brew switch mysql 5.7.20

Solution 3 - Mysql

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.

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

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).

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.

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

Solution 4 - Mysql

There is another option.

A. Steps:

  1. Install MysqlWorkbench
  2. copy mysql/mysqldump from /Applications/MySQLWorkbench.app/Contents/MacOS to preferred place.
  3. Use mysqldump from command line

Should also work when you remove MysqlWorkbench.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionD.R.View Question on Stackoverflow
Solution 1 - MysqlErik TheoboldtView Answer on Stackoverflow
Solution 2 - MysqlMattView Answer on Stackoverflow
Solution 3 - MysqlBill KarwinView Answer on Stackoverflow
Solution 4 - MysqlKarol MurawskiView Answer on Stackoverflow