33

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.

Shadow
  • 30,859
  • 10
  • 44
  • 56
D.R.
  • 1,676
  • 2
  • 16
  • 37

4 Answers4

72

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.

Erik Theoboldt
  • 1,296
  • 1
  • 13
  • 19
  • 3
    The PATH update works. Note: After updating the bash_profile, run `source ~/.bash_profile` to reload it and put the changes in effect. – jwinn Aug 09 '19 at 20:33
39

See Eriks answer for the new mysql-client pkg 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 mysql@5.6 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
Matt
  • 51,189
  • 6
  • 117
  • 122
11

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.

Bill Karwin
  • 462,430
  • 80
  • 609
  • 762
  • 1
    Thank you for your answer. I thought so too, but have checked, cause I can miss something. I have 128Gb on my mac and it's...horrible :) Never thought, that I'll advance to a strong middle dev for quite a short period of time. I'll buy a new mac soon. – D.R. Nov 19 '17 at 18:47
5

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

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
Karol Murawski
  • 139
  • 1
  • 7