Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install only mysqldump on macOS

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.

like image 272
D.R. Avatar asked Nov 19 '17 18:11

D.R.


People also ask

Can you install MySQL on Mac?

MySQL for macOS is available in a number of different forms: Native Package Installer, which uses the native macOS installer (DMG) to walk you through the installation of MySQL. For more information, see Chapter 2, Installing MySQL on macOS Using Native Packages. You can use the package installer with macOS.


4 Answers

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.

like image 147
Erik Theoboldt Avatar answered Sep 25 '22 02:09

Erik Theoboldt


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 [email protected] 

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 
like image 37
Matt Avatar answered Sep 24 '22 02:09

Matt


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.

like image 39
Bill Karwin Avatar answered Sep 23 '22 02:09

Bill Karwin


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

like image 20
Karol Murawski Avatar answered Sep 22 '22 02:09

Karol Murawski