1

I installed MySQL:

installed

but MySQL certainly isn't on the path when I open a terminal, nor do I see it in applications, as I seem to recall Windows handles MySQL.

Ian C.
  • 45,969
Thufir
  • 241
  • 1
  • 5
  • 17

2 Answers2

5

My favourite way to install and run MySQL is via the Homebrew package manager. With Homebrew installed it's as straightforward as:

brew install mysql

This gets you the server and the command line connection tool. It's setup to run with no password, so it's not suitable for production use, but it's perfect for developing with. Homebrew takes care of putting everything you need on your PATH for you, no digging around in .app bundles for binaries.

Once installed, to connect:

mysql -uroot

To have launchd start mysql at login:

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

Then you can start it with:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Or if you don't care about having it start on machine boot/restart, you can just run the server directly with:

mysql.server start

The configuration file it reads will be in at /usr/local/etc/my.cnf.

Bonus: having Homebrew on your system puts you one command call away from installing all kinds of other packages. It's a reasonable package manager without a lot of fluff and cruft.

Ian C.
  • 45,969
  • this is my preferred way of doing things. I've been looking at macports, it's just so many hoops to jump through, depending on OS version, etc, etc. xcode version... Mac would be so much better if homebrew/macports/whatever was just available from the app store..sigh. – Thufir Mar 23 '15 at 02:28
1

The mysql installer works just fine, I've used it many times.

However, it will never appear in Applications as it is not a GUI application.

And it won't appear in your terminal path unless you put it there. Mysql lives in /usr/local/mysql/bin/mysql. If you also install the Mysql preference pane you can start and stop mysqld via System Preferences.

There is absolutely no need to drag in an entire package manager (homebrew / macports / fink) for something that has an installer. That's like calling a moving company to put your dishes away.

Also consider that package managers typically require XCode as well - that's an additional 6+ Gb to install. Oracle's installer is 172Mb.

paul
  • 2,665
  • 12
  • 8
  • There is no need, but it is just more practical to install software using Homebrew, given that it is highly scriptable, it harmonizes the installation processes of different software packages and its formulas are regularly updated. It also often offers more options than a regular installer (bindings, compile options, etc...). I agree that Mysql's binary distribution is totally fine, but there is nothing wrong with installing it through Homebrew if we don't need all the bells and whistles coming with Oracle's installer package. – retrography Mar 20 '15 at 14:13
  • Oracle's .pkg has no bells + whistles. And now that you are dependent on homebrew rather than knowing how to setup your shell properly what will you do on a different box where you can't install homebrew / port / fink etc? – paul Mar 22 '15 at 23:53
  • If you can't install Homebrew on a machine you won't have sufficient permissions to install a pkg-based application and run MySQL as a daemon, so your point is moot. In any case, you've made your point and posted your answer. Your dislike of Homebrew for managing packages is noted. – Ian C. Mar 23 '15 at 00:15
  • @IanC. mysql is installed by default on many, many systems, like shared webhosting. You get to edit your path and .profile but not install things - doing it the xyz-package-manager way means you don't learn the more portable way. So my point is very pointed. And FYI, I have XCode, fink, macports AND homebrew on my desktop, they are used whenever something needs to be compiled. – paul Mar 23 '15 at 00:42
  • I'll have to install workbench seperately, presumably. I'll check that next time I'm on a Mac. I have nothing against homebrew or macports, just seems like jumping through hoops, to me, to install them. I was thinking of workbench, not MySQL server itself. – Thufir Mar 23 '15 at 02:21
  • 1
    @Thufir: mysqlworkbench is in any case a separate package. You can download it from oracle's website or set it up using homebrew cask, if you prefer to have a scriptable installation. – retrography Mar 23 '15 at 13:22
  • @paul: For the record Homebrew does not need a full installation of the 6GB Xcode behemoth. It does need Xcode CLT though, but that's a much smaller package. What I do for the different boxes is that, I always run an init script on them. I have one for OSX boxes and one for Debian/Ubuntu boxes. Both scripts install everything using package managers, and then amend the conf files. It takes between 5 to 10 minutes to run the scripts and afterwards you have an operational machine. I use the same method with EC2 VMs and Docker containers. – retrography Mar 23 '15 at 13:36