问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27325754/setup-mysql-5-6-with-macports