Need help activating Macports install of MySQL5 on Snow Leopard

Scott Haneda talklists at newgeo.com
Thu Dec 17 19:46:31 PST 2009


On Dec 17, 2009, at 6:56 PM, William H. Magill wrote:

> On Dec 14, 2009, at 8:51 PM, Ryan Schmidt wrote:
>
>>> I don't know if I still need to do more things using the macports  
>>> mysql tools (and which ones), or if I need to find something  
>>> specific to generic Mysql.
>>> I'm assuming I am tripping over all of the things which only ever  
>>> need to be done once when MySQL is first installed, and never  
>>> again under updates.
>>>
>>> So, I'm looking for some kind of tutorial/cookbook for  
>>> "installing" MySQL5 on Snow Leopard.
>>>
>>> Quite frankly, at this point, I don't know what i don't know, but  
>>> assume it to be substantial.
>>
>> Give the MySQL section of the MAMP how-to a try and please make any  
>> necessary corrections (or let us know and we'll make them).

I have been meaning to do a start from scratch install on a clean  
system and write up some new install notes, just have not had time.   
Let me see if I can answer some of your issues...

> I'll let you folks make the changes as I don't feel confident enough  
> in my conclusions, since this is my first time through.
>
> Ok...  Installing mysql-server apparently was the big thing.

Yes, that installs the launchd item that will start it all the time.

> Had to completely remove (not just port uninstall) the macports  
> MySql5 installation including:
>        /opt/local/etc/mysql5
>        /opt/local/var/db/mysql5
> 	/opt/local/var/run/
> to start over again.

I would guess, that because at some point, you did some work in MySql,  
or something changed about those directories.  If they are not empty,  
it is my understanding, ports is not going to remove them.  They very  
well may have important data in them.

> Miscellaneous things I've noticed...
> 1- MAMP ... Under Snow Leopard, the pre-existing userid/groupid for  
> mysql is "_mysql" -- note the preceding underscore.

Same for 10.4 up I believe, you can use them rather interchangeably.    
If you look in httpd.conf (Apache) you can see the user is set to  
"User www" but "User _www" will work just fine as well.  I think the  
general idea is use the underscore ones for under uid 500 stuff, and  
the normal ones for over uid 500 stuff.  If you look at the database  
of where the user id's are stored, you will see they are "aliased" to  
be equivalent.  At least, that is my take on it, I could be wrong.

> However, the script: "sudo -u mysql mysql_install_db5" does  
> correctly set the ownership permissions on the files mentioned in  
> the next 3 lines
> (to "_mysql", not "mysql")

They all end up the same, take this test case:
$mkdir -p ~/Desktop/test; cd ~/Desktop/test
$touch file1
$touch file2
$ls -la
	-rw-r--r-- 1 me  staff 0 Dec 17 19:04 file1
	-rw-r--r-- 1 me  staff 0 Dec 17 19:04 file2

$sudo chown mysql file1
$sudo chown _mysql file2

$ls -la
-rw-r--r--  1 _mysql  staff    0 Dec 17 19:04 file1
-rw-r--r--  1 _mysql  staff    0 Dec 17 19:04 file2

> 2- The install script "port install myql5-server" ends with
>    --->  Activating mysql5-server @5.1.41_0
> but does, in fact NOT activate the server -- the comment earlier in  
> the script,

Maybe a valid point, but I think there are two different terms for  
activating.  It is activating the port, which it has done.  It is not  
making any claim to "loading the server" or "starting the server".  It  
is a little confusing, but in most cases, there are not launchd items  
to deal with, and it makes sense in those cases.

MacPorts does not like operating outside of it's prefix, this is a  
great thing.  However, there are places, like /etc/pam.d and the  
system and user LaunchDaemons and LaunchAgents that simply can not run  
inside the MacPorts prefix.

Macports is as clean as I can think it can be, with a symblink in this  
case.

Actually, getting a little OT here, why are there mysql5 and mysql5- 
server ports?  If they are identical other than the launchd item, how  
about just ui messaging a statement that says "if you want to run this  
as a server, cp and load the file with these instructions..."

> 	###########################################################
> 	# A startup item has been generated that will aid in
> 	# starting mysql5-server with launchd. It is disabled
> 	# by default. Execute the following command to start it,
> 	# and to cause it to launch at startup:
> 	#
> 	# sudo launchctl load -w /Library/LaunchDaemons/ 
> org.macports.mysql5.plist
> 	###########################################################
>
> should probably be output at that point.

That should be printed when the port is installed, which last I tried  
it was what I saw, did you not get that result?  If you did not start  
it, then that may explain why you are not able to run some of the  
commands below.

> 3- in the output from "sudo -u _mysql mysql_install_db5" is the  
> comment:
>
> 	"You can test the MySQL daemon with mysql-test-run.pl
> 	cd /opt/local/mysql-test ; perl mysql-test-run.pl"
>
> except that the directory "/opt/local/mysq-test" does not exist nor  
> does the perl script.

You are missing an l in "mysq-test", though I too do not have those  
files or dirs.

> HOWEVER, There is a man page for "mysql-test-run.pl"
> (Note: there is also a man page for "mysql-test-run.pl" also exists,  
> but no script)

All I have are man pages as well.

> sudo find . -name *\test\* -print  ... yields:
>
> ./bin/mysql_client_test5

[snip...]	

You can also run `port contents mysql5` or `port contents mysql5- 
server` and see what was installed, which gives me this:
http://pastie.org/748235

I too, also see missing files, though I believe the files are not  
missing, and some general cleanup needs to be done.  In all my mysql  
installs, I have never seen those files as test files.

> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>
> 4-  One thing which I don't understand (may just be my lack of MySQL  
> knowledge) is why the  commands...
> (from the install output)
>
> 	/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
> 	/opt/local/lib/mysql5/bin/mysqladmin -u root -h  
> shianbrae.mcgillsociety.org
>
> both fail...
> 	/opt/local/lib/mysql5/bin/mysqladmin -u root password 'xxx'
> 	/opt/local/lib/mysql5/bin/mysqladmin: connect to server at  
> 'localhost' failed
> 	error: 'Access denied for user 'root'@'localhost' (using password:  
> NO)'
>
> If you try to run them a second time.
>
> but the command:  mysqladmin5 -u root -p password <new-password>
> from the MAMP does work, prompting you for the existing password.

Good questions, I would like to know the difference in mysqladmin in / 
opt/local/lib/mysql5/bin and mysqladmin5 in /opt/local/lib/mysql5/bin  
and how we can clean this all up.

This seems to be a documentation issue, and a port layout issue.  
`mysqladmin` should work, it has a man page that goes with it, and is  
how you generally do this on a not MacPorts install.  So far, I do not  
believe you have done anything wrong, but this is getting rather  
confusing.

If I get a spare moment, I will look at the port file(s) and see if I  
can see what is happening.

> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>
> 5- if you "sudo port uninstall mysql5-server"
> It claims :
>
> --->  Deactivating mysql5-server @5.1.41_0
> --->  Uninstalling mysql5-server @5.1.41_0
>
> But the server continues to run.  And, since the plist file is now  
> gone, you can't "unload" it...

When you now you have a 'server' type app running, you have to just  
know to unload the launchd item first.  You have a few options, brute  
force it with a reboot, the plist will not be there anymore, and it  
will not be able to load

Run `sudo launchctl list`
You will get back a few things;
$sudo launchctl list | grep -i mysql
Password:
143	-	0x10c110.mysqld
143	-	0x10b180.mysqld
93	-	org.macports.mysql5

* If someone could explain items 143 to me, would love to know about  
those.

But you can also remove/start/stop by label, which you now know.  I  
like label better, easier to remember, no paths to fiddle with.   From  
the man page:
( `man launchctl` )

      remove job_label
               Remove the job from launchd
               by label.

      start job_label
               Start the specified job by
               label. The expected use of
               this subcommand is for
               debugging and testing so
               that one can manually
               kick-start an on-demand
               server.

      stop job_label
               Stop the specified job by
               label. If a job is on-demand,
               launchd may immediately
               restart the job if launchd
               finds any criteria that is
               satisfied. Non-demand based
               jobs will always be restarted.
               Use of this subcommand is
               discouraged. Jobs should
               ideally idle timeout by them-
               selves.

So I think in your case something like
sudo launchctl remove org.macports.mysql5
( * Note the lack of the .plist in the name, we are removing by label  
here, which may not always match the filename, though in 99.999% of  
the cases, they do )

The server continues to run, even though most of the files are gone,  
because that is how computers work :)  Run an app, it is loaded into  
memory.  I could sudo rm -rf /Application_/Mail.app and keep writing  
you this email, and all would be well, probably for a longer time than  
you would ever suspect.

A nice story was once told about how a mis-placed rm -rf got caught  
about 90% to completion, but a shell was open, with very little  
access.  Since so much stuff was still in memory, a lot of work was  
still able to be done, and even an backup was restored, sans a reboot  
I believe.

MySql for you, is still running, because MacPorts removed what it  
could, but all your data files and pids and the rest are allowing it  
to live on. Brave (I mean stupid) people use this to their advantage  
to wildly update php5 on a production server :)

> sudo launchctl unload -w /Library/LaunchDaemons/ 
> org.macports.mysql5.plist
> launchctl: Couldn't stat("/Library/LaunchDaemons/ 
> org.macports.mysql5.plist"): No such file or directory
> nothing found to unload -- and, naturally, you can't kill it because  
> Launchd will respawn it, forcing a reboot

Pretty sure we got this covered, to the best of my personal knowledge.

> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>
> So, the short is, I have the server working  (accordng to the MAMP  
> page) and now have to figure out how to
> authorize users!

Once you get it up and running, I assume you have apache2 up and  
running.  I also am going to assume you have php5 up and running.  Do  
a `sudo port install php5-mcrypt`, this is needed by phpMyAdmin.   
Restart Apache.

Load up http://localhost and you should see "It works!", this is  
served out by the path:
/opt/local/apache2/htdocs/

Download phpMyAdmin, rename it it something easier to type, like "p"  
and drop in in
/opt/local/apache2/htdocs/p/

Edit the config file, you need only edit one line, the secret key  
value, and if this is a local box, don't worry too much about it.

Hit up http://localhost/p
It will ask you to login, use root and your password.  Then go into  
the permissions.  I usually, on a production machine, set all access  
to localhost when adding new users.  I will update the root username  
to a username I like *instead* of root.  Some of my phpMyAdmins are  
public facing, and while they are http auth protected, and SSL'd, I  
still do not like giving away 50% of the login data.

> Time to break down and RTFM.


I think you did pretty good with what you had.  Sounds like you are  
going along just fine.  This list is here to help, this is my favorite  
list for the great people here.

Hope this helps.
-- 
Scott * If you contact me off list replace talklists@ with scott@ *



More information about the macports-users mailing list