8

MacOS 10.10, up-to-date macports. I want to get mysql 5.6 on port 3306.

1) Installing

port install mysql56-server mysql56

installs mysql56@5.6.22_0, after that

which mysql

or

which mysql56

returns nothing.

So first question is where is mysql client?

2) Configuring

Installation script suggests to do

sudo -u _mysql /opt/local/lib/mysql56/bin/mysql_install_db

then

/opt/local/lib/mysql56/bin/mysqladmin -u root password 'new-password'

which asks for running server and I start it by

cd /opt/local ; /opt/local/lib/mysql56/bin/mysqld_safe &

then mysqladmin complains about socket and I comment --skip-networking in /opt/local/etc/mysql56/macports-default.cnf and after that command goes ok. then

/opt/local/lib/mysql56/bin/mysqladmin -u root -h bp.local password 'new-password'

which returns

error: 'Host '10.0.1.9' is not allowed to connect to this MySQL server'

I really don't know what to do here without mysql client. And I'm kind of stuck. Any suggestions?

coviex
  • 504
  • 5
  • 20

1 Answers1

16

MacPorts installs MySQL and its derivatives in a way that they don't conflict with each other and can be installed at the same time. That includes putting the mysql binary in non-standard paths. You can locate your binary using port contents mysql56 | grep -E '/s?bin/'. MacPorts also comes with a selection mechanism that creates symlinks for your convenience in /opt/local/bin. To make MySQL 5.6 your default, run sudo port select --set mysql mysql56.

To start the server, you can use MacPorts' daemon control functions (that are a frontend to launchd): sudo port load mysql56-server will start the server and ensure it is running after a reboot, sudo port unload mysql56-server will undo that and stop the server.

The --skip-networking is the default to make running multiple MySQL versions side-by-side possible. See port notes mysql56 for more information.

You can connect to MacPorts' MySQL using a unix socket, although I don't recall its path from the top of my head. I'm sure http://trac.macports.org/wiki/howto/MAMP has them, though. To connect to your local server, you should use localhost or 127.0.0.1 instead of bp.local, which apparently resolves to a private IP address and thus goes through the IP stack of your OS, rather than through the loopback interface.

neverpanic
  • 2,918
  • 18
  • 27
  • I was trying `port select` but with only one hyphen :(. And as I understand you have to install `mysql_select` to be able to use it. @neverpanic if could you add commands for mysql start without adding to boot and for restart this answer of yours would be perfect. – coviex Dec 06 '14 at 23:53
  • `mysql56` depends on `mysql_select`, so you'll always have it installed when you have `mysql56` installed (unless you forced MacPorts to ignore the dependency). Unfortunately, launchd always keeps daemon state across reboots AFAIK, so there's no way to "start until next reboot" with launchd plists. I guess your start command would work for that case, though. Just make sure you use the same environment and user as the plist does, though. – neverpanic Dec 07 '14 at 22:56
  • You can find the socket path by running `/opt/local/lib/mysql56/bin/mysqladmin -u root -p variables` and looking for the line `socket`. For me, it was: `/opt/local/var/run/mysql56/mysqld.sock`. – ilpssun Aug 29 '15 at 12:07