Opened 13 years ago

Closed 13 years ago

#30678 closed defect (wontfix)

mysql5 should not read /etc/my.cnf

Reported by: jeremyhu (Jeremy Huddleston Sequoia) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.0.1
Keywords: Cc:
Port: mysql5

Description

cid:~ admin$ cd /var/mysql/
cid:mysql admin$ ls -al
total 0
drwxr-xr-x   2 _mysql  wheel    68 Aug  9 13:53 .
drwxr-xr-x  37 root    wheel  1258 Aug  9 13:26 ..
cid:mysql admin$ sudo launchctl start org.macports.mysql5
cid:mysql admin$ ls -al
total 0
drwxr-xr-x   3 _mysql  wheel   102 Aug  9 13:53 .
drwxr-xr-x  37 root    wheel  1258 Aug  9 13:26 ..
srwxrwxrwx   1 _mysql  wheel     0 Aug  9 13:53 mysql.sock

MacPorts should not be placing mysql.sock in /var/mysql as that is owned by Apple's MySQL server. This interference causes in-place upgrades from SL Server to Lion Server to fail.

Change History (15)

comment:1 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

On my system it's in /opt/local/var/run/mysql5/mysqld.sock where it's supposed to be. Are you sure you haven't asked for it to be in /var/mysql/mysql.sock? Check your my.cnf settings file.

comment:2 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Ok, then the problem seems to be that mysql5-server doesn't install a my.cnf:

$ port contents mysql5-server
Port mysql5-server contains:
  /Library/LaunchDaemons/org.macports.mysql5.plist
  /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper
  /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist
  /opt/local/var/db/mysql5/.turd_mysql5-server
  /opt/local/var/log/mysql5/.turd_mysql5-server
  /opt/local/var/run/mysql5/.turd_mysql5-server

comment:3 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

So by default, it is using /var/mysql (which it shouldn't)

comment:4 in reply to:  2 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

Ok, then the problem seems to be that mysql5-server doesn't install a my.cnf:

Well no, it is correct and good and right that it doesn't install a my.cnf. Instead, the mysql5 port installs sample my.cnf files that you can copy and customize as desired.

$ port contents mysql5 | grep cnf$
  /opt/local/share/mysql5/mysql/my-huge.cnf
  /opt/local/share/mysql5/mysql/my-innodb-heavy-4G.cnf
  /opt/local/share/mysql5/mysql/my-large.cnf
  /opt/local/share/mysql5/mysql/my-medium.cnf
  /opt/local/share/mysql5/mysql/my-small.cnf

comment:5 in reply to:  3 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

So by default, it is using /var/mysql (which it shouldn't)

That shouldn't be the case. mysql5 is configured with --with-unix-socket-path=/opt/local/var/run/mysql5/mysqld.sock so that should be the default, unless you have specified otherwise in your my.cnf. I have not specified otherwise in my my.cnf, and that is what it is on my system.

Remember that mysql looks for my.cnf in many places, including /etc/my.cnf.

comment:6 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Right, that's my point as to why it's wrong. It should be checking ${prefix}/etc/cnf and not /etc/my.cnf ... It should never use /etc/my.cnf because that one does not belong to it.

comment:7 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

It does check ${prefix}/etc/mysql5/my.cnf, but all versions of MySQL—MacPorts', the official binaries, etc.—also check /etc/my.cnf. That's how MySQL is documented to function—see the paragraph beginning "On Unix, Linux and Mac OS X, MySQL programs read startup options from the following files, in the specified order" in the MySQL documentation—so I don't know that we should change it in MacPorts.

comment:8 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Port: mysql5 added; mysql5-server removed
Summary: mysql5-server places socket in /var/mysql which breaks in-place upgrade from SL Server to Lion Servermysql5 should not read /etc/my.cnf

comment:9 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

What about editing the startup script to fail to start if ${prefix}/etc/my.cnf isn't present? It can print a warning message that uses should create that file. If someone really wants it to use /etc/my.cnf, they can comment that out or just use a symlink.

comment:10 in reply to:  9 ; Changed 13 years ago by pixilla (Bradley Giesbrecht)

Replying to jeremyhu@…:

What about editing the startup script to fail to start if ${prefix}/etc/my.cnf isn't present?

This would not be good. There is no documented requirement that ANY my.cnf exist.

It can print a warning message that uses should create that file. If someone really wants it to use /etc/my.cnf, they can comment that out or just use a symlink.

The mysql option files (my.cnf) are documented by the software authors. The MacPorts mysql5 port honors the mysql documentation.

comment:11 in reply to:  10 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Replying to pixilla@…:

Replying to jeremyhu@…:

What about editing the startup script to fail to start if ${prefix}/etc/my.cnf isn't present?

This would not be good. There is no documented requirement that ANY my.cnf exist.

It can print a warning message that uses should create that file. If someone really wants it to use /etc/my.cnf, they can comment that out or just use a symlink.

The mysql option files (my.cnf) are documented by the software authors. The MacPorts mysql5 port honors the mysql documentation.

Right, well we have a problem in that if mysql-server is installed and not configured (as was my case because I install a ton of ports just to make sure they build and install), it can cause the server migration scripts to fail because it will result in MacPorts mysql "claiming" /var/mysql and the migration scripts will fail to migrate Apple's MySQL to that location from the previous system.

How do you want to handle this? I'm fine with it being documented on the upgrade page in the wiki if we don't want to actually change the software itself.

comment:12 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

It sounds like on your system you had a file /etc/my.cnf that specified that the socket should live in /var/mysql/mysql.sock, and so MacPorts MySQL honored that request, as would any other distribution of MySQL. If you had not had that file with those contents MacPorts MySQL would have used its default socket at /opt/local/var/run/mysql5/mysqld.sock.

Are you saying that the file /etc/my.cnf was not created by you but was provided by Apple on Mac OS X Snow Leopard Server? If so I can see how that would cause this problem now. But I had also understood that Mac OS X Lion Server does not include MySQL anymore. And of course Mac OS X client has never included MySQL. So I don't see how you're going to be able to migrate a Snow Leopard Server Apple MySQL setup to Lion Server anyway, without finding another way (like MacPorts) to install MySQL.

By "'claiming' /var/mysql" are you saying that MacPorts mysqld was creating its socket in that directory and keeping it open? That should only have happened if MacPorts mysqld was started. And if you started MacPorts mysqld, that's a good indication that you're actually using it for something, and that perhaps Apple's migration script was right in not trying to interfere with it.

comment:13 in reply to:  12 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Replying to ryandesign@…:

Are you saying that the file /etc/my.cnf was not created by you but was provided by Apple on Mac OS X Snow Leopard Server?

Correct

If so I can see how that would cause this problem now. But I had also understood that Mac OS X Lion Server does not include MySQL anymore. And of course Mac OS X client has never included MySQL. So I don't see how you're going to be able to migrate a Snow Leopard Server Apple MySQL setup to Lion Server anyway, without finding another way (like MacPorts) to install MySQL.

Lion includes MySQL for in-place upgrades from SL Server to Lion Server, but it is an older version. Erase installs of Lion Server do not have MySQL.

By "'claiming' /var/mysql" are you saying that MacPorts mysqld was creating its socket in that directory and keeping it open?

Yes

That should only have happened if MacPorts mysqld was started. And if you started MacPorts mysqld

I did not start it myself. It was started by launchd because I had the mysql5-server port installed (as part of install testing as mentioned above) but not configured.

that's a good indication that you're actually using it for something, and that perhaps Apple's migration script was right in not trying to interfere with it.

Unfortunately, I didn't realize that the launcdaemon was enabled by default as I never used it.

comment:14 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

MacPorts launchd plists are not enabled by default; you have to explicitly start them by typing e.g. "sudo port load mysql5-server".

comment:15 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: wontfix
Status: newclosed

I think this should just be closed as behaves correct.

Note: See TracTickets for help on using tickets.