How to use php5 port with MySQL5 binary?
Ryan Schmidt
ryandesign at macports.org
Sun Apr 15 02:46:21 PDT 2007
On Apr 15, 2007, at 01:09, Karl Timmermann wrote:
> On Apr 14, 2007, at 5:29 PM, Ryan Schmidt wrote:
>
>> The reason you should not do this, or at least the reason why I do
>> not presently include a variant like this in the php5 portfile, is
>> that it is MacPorts policy to use its own versions of software
>> unless there is a compelling reason not to. What is your reason
>> for not using the MacPorts version of mysql5?
>
> First, thank you very much for the instructions on how to modify
> the port file. As to your other question, I have a lot of programs
> that are looking for mysql in the normal place.
These "lot of programs": are we talking about shell scripts here or
php scripts or compiled C programs or what kinds of programs?
> Also, I mentioned in another post that I was having problems with
> localhost mapping to the socket file - the port uses a custom
> location for the socket file, and a lot of my programs don't map
> correctly when connecting to localhost.
Yes, we need to solve that problem, and I am attempting to help you
with that. If these other programs of yours are shell scripts, and
they are using the MacPorts mysql5 client, then they should already
know where this custom socket file is without being told anything. If
these other programs are binaries which are linking with the MacPorts
mysql5 libraries (for example, if you're using a php script running
in the MacPorts version of php5 linked against the MacPorts mysql5
libraries), then it too will already know where the socket is and
everything will just work. If you're using a php compiled against
someone else's MySQL libraries and therefore it doesn't already know
where the socket is, you can tell it by modifying the appropriate
directive in the php.ini*. I need more information about your setup
to try to understand why it's not "just working" for you.
* The exception might be if you're using mysqli in php5. I haven't
yet figured out how to tell mysqli where the socket is. This may be a
php bug, a documentation deficiency, or a Ryan didn't look hard enough.
> Another reason is the MySQL binary comes with a nice pref pane to
> turn it on and off and to start it up on boot up. I guess I just
> like it more "Mac like". :-)
The prefpane does not start MySQL at boot up. The StartupItem does.
The prefpane merely changes a setting somewhere (well, a line in /etc/
hostconfig, to be exact) that tells the StartupItem whether or not to
start the mysqld daemon when your Mac boots. And the prefpane can
also start and stop the daemon immediately.
MacPorts provides no prefpanes, true. Instead, when on 10.4, it uses
the standard method of starting and stopping daemons: launchd. To
start mysql5 now, and start it at every system startup, you use:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
To stop mysql5 now, and stop it from starting at every system
startup, use:
sudo launchctl unload -w /Library/LaunchDaemons/
org.macports.mysql5.plist
Once you know these commands, this knowledge applies to *all* daemons
installed by MacPorts (and any daemons installed outside of MacPorts
that use launchd). Whereas your MySQL prefpane is a solution only for
MySQL, and each other daemon you have installed may have its own way
of being started and stopped, and that's more confusing. Better to
learn the One True Way to start daemons and use it for everything.
Maybe someone has even written a prefpane to manage all your
LaunchDaemons? That would be cool.
> However, perhaps I could use the ports if I made proper symbolic
> links everywhere - then everything should work, including the pref
> pane. I could do this, or modify the port file to change the file
> paths. Do you recommend this instead?
I would not really recommend modifying the portfile. The reason is
that your changes will be overwritten next time you port sync. Unless
you set up your own local port tree. Which you could do. And keep
your own private version of php5. But then you won't receive any
updates I make to the real php5 portfile. So that might be bad.
Making symlinks might work. But let's understand first where you
think you need to make symlinks and why. Is it because you have some
scripts that call /usr/local/mysql/bin/mysql directly? If so, then
your choice is either to replace those calls with calls to /opt/local/
lib/mysql5/bin/mysql (or /opt/local/bin/mysql5, same difference), or
go to /usr/local, make a directory mysql, make a directory bin inside
that, and make a symlink mysql in that. Your prefpane probably needs
to call mysqladmin to do its thing, so if you insist on continuing to
use it you might make a symlink to that too. Though, now that I think
about it, the prefpane may also assume you're using the old
StartupItem from mysql.com and it might not play will with the new
LaunchDaemon start/stop method used by the MacPorts version.
More information about the macports-users
mailing list