Installing Mysql5 port on top of an existing mysql5 on Leopard and using Rails

Chris Janton face at CentosPrime.COM
Wed Apr 29 08:15:02 PDT 2009

>>> If this is the case, shut down mysql server.  You should find your  
>>> old data at
>>> /usr/local/mysql/data
>>> You should see your new mysql data from macports at:
>>> /opt/local/var/db/mysql5
>> That accomplishes getting the data moved to where the mysql5  
>> installation wants it to be by default, but it doesn't accomplish  
>> having your data where it is independent of whose distribution of  
>> mysql5 that you use - Apple, MySQL, ports
> True, but I have been under the impression, that when you use ports,  
> you want to keep as much as possible within the port dirs.  Sure,  
> you can move things to where you like, and may even need to, for  
> example, put http docs on a faster raid or something.

ports is being used to maintain applications. MySQL is an application,  
but it's all about the data that you store and use, not the  
application itself.

> I was sort of under the impression the OP was doing small local  
> development, and feel his setup should be contained within ports, if  
> for anything, for being on the same page as everyone else.

Being on the same page about the application, fine. Putting everything  
that you need in /opt/local? Not sure that's the right thing.

>> Lots of "applications" let you specify how to get to the mysql data  
>> via the socket interface - you may just want to change the config  
>> file for the app...
>> There's a very simple way to keep your data in one place - use /etc/ 
>> my.cnf to define things.
> I could not find out where the ports version of mysql5 looks for  
> my.cnf as defaults.  Do you know where it is looking within the opt/ 
> local area?  I do not have a cnf file at /etc or /opt/local/etc

The sample my.cnf file has this at the top...

# This file can be simultaneously placed in three places:
# 1. /etc/mysql/my.cnf to set global options.
# 2. /var/lib/mysql/my.cnf to set server-specific options.
# 3. ~/.my.cnf to set user-specific options.

My guess is that 2 would be /opt/local/lib/mysql5

> The only reference I can find to it now is
> /opt/local/var/macports/sources/ 
> databases/mysql4/files/my.cnf
> Of course, that is not the correct one, and is part of the mysql4  
> build files.
> I personally believe that the my.cnf file should live in /opt/local/ 
> etc/my.cnf in the case of MacPorts.

It's not about MacPorts - it's about MySQL.

> Something is defining the sock file, I just can not find it.

The default location for the sock file is "built" into the  
mysql_config program

$ mysql_config --socket

Many applications that want to "talk" to MySQL will use mysql_config  
to find out where the socket is.

>> My example uses the "default" location of data based on the OS X  
>> Server definitions - you could just as easily use "/var/lib/mysql"  
>> like Centos, or whatever.
>> in the [mysqld] section add
>> basedir = /opt/local
>> datadir = /var/mysql
>> in the [client] section
>> socket = /var/mysql/mysql.sock
>> I added the following set of definitions to "make sure" that things  
>> got it straight
>> # face - 20070227
>> [mysqld_safe]
>> basedir = /opt/local
>> datadir = /var/mysql
>> [mysql.server]
>> basedir = /opt/local
>> datadir = /var/mysql
>> [mysql_config]
>> socket = /var/mysql/mysql.sock

In the MySQL startup scripts - located at /opt/local/share/mysql5/ 
mysql/mysql.server - there are notes about
setting defaults, etc. MySQL gets built with the prefix of "/opt/ 
local", so everything starts from there - including what you see in  
the notes...

# If you install MySQL on some other places than /opt/local, then you
# have to do one of the following things for this script to work:
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example  
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir  
#   below.
# If you want to affect other MySQL variables, you should make your  
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

my_print_defaults also indicates the expected order of configuration  

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/local/etc/mysql5/my.cnf ~/.my.cnf

> I do think it is worth considering, that MacPorts tries to keep  
> things contained in its own little home.  For me, it certainly makes  
> backing up data, and knowing that all but launchd items are in one  
> place. For me, I like that methodology, unless I have a really good  
> reason to over-ride it, such as needing to move active files off the  
> boot drive.

until someone does the "blow away /opt/local" to rebuild all of the  
Chris Janton  - face at CentosPrime dot COM
Netminder for Opus1.COM

More information about the macports-users mailing list