Need help activating Macports install of MySQL5 on Snow Leopard

Scott Haneda talklists at newgeo.com
Sat Dec 19 01:11:37 PST 2009


On Dec 18, 2009, at 10:21 PM, William H. Magill wrote:

> On Dec 17, 2009, at 10:46 PM, Scott Haneda wrote:
>>> 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.
>
> Yes. mysql_install_db5 populates those directories. And the server  
> creates the log file as soon as it is launched, so they were  
> definitely not empty.
>
> Need the classic option -- "I screwed up, lets start all over again  
> from scratch, make EVERYTHING go away"

I just nuked all of mysql, php, apache2, the whole MAMP stack, in  
order to make sure I could reinstall, and then nuke it all again and  
write a wiki page that outlines what I did.

I ran into issues again, did not doc them, as I assumed it would work  
fine.  I will do it again.  You can also use `port contents portname  
 >> ~/Desktop/portfiles.txt`.  I am sure there is a way to pass that  
to xargs and send in rm -rf, or I just issue a find regex ^ replace  
'rm -rf ' to get a command file that I can rip through to make sure I  
delete everything.  First I issue `sudo port uninstall portname` then  
rip though the file to remove the leftovers.

>>> 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
>
> Ok, never looked beyond /etc/passwd -- guess I'll have to learn Open  
> Directory next...
> and just when I thought I finally understood NIS... :)

I think on OS X, /etc/passwd is pretty useless.  I mean, not entirely,  
but none of my local user accounts are in it at all. I do not know a  
lot about that part of the intervals of OS X.

> shianbrae> dscl . -read /Users/mysql
> AppleMetaNodeLocation: /Local/Default
> GeneratedUID: FFFFEEEE-DDDD-CCCC-BBBB-AAAA0000004A
> NFSHomeDirectory: /var/empty
> Password: *
> PrimaryGroupID: 74
> RealName:
> MySQL Server
> RecordName: _mysql mysql
> RecordType: dsRecTypeStandard:Users
> UniqueID: 74
> UserShell: /usr/bin/false

Ahh, you found it, so there you have it, Record Name seems to accept  
both versions.

>> 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..."
>
> I believe the other difference (and why I installed server not just  
> client) is that the server install creates other directories and  
> properties which the client install does not.

In looking at the portfiles I have ( `port edit mysql5` and port edit  
mysql5-server` ), that does not seem to be the case.

mysql5-server:

depends_run \
     port:mysql5

So the -server one seems to call out to the non server one, and the  
server one more or less just instals the plist.  It also adds some  
users, which I am not sure it needs to do, as I seem to always recall  
_mysql being available in a stock install, though I may not be thining  
back far enough in OS versions.

I forgot the -server and just had mysql5 installed, so I went ahead  
and did `port install mysql5-server` and it happened in seconds,  
telling me it did not do a lot more than install the launchd plist.

Open them and compare, you can learn a lot from them.

>> 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.
>
> However, if you look at mysql.com they mention, apparently,  /usr/ 
> local/mysql-test  -- as where the test suite installs.
>
> /usr/local apparently being the default installation directory for  
> the server.
>
> 	http://dev.mysql.com/doc/refman/5.1/en/configure-options.html
>
> 	"The first command changes the installation prefix so that  
> everything is installed under /usr/local/mysql
> 	rather than the default of /usr/local. The second command preserves  
> the default installation prefix, but
> 	overrides the default location for database directories (normally / 
> usr/local/var) and changes it to"
>
> Test suite info is here.
> 	http://dev.mysql.com/doc/mysqltest/en/test-programs.html
>
> 	http://dev.mysql.com/doc/mysqltest/en/mysql-test-run-pl.html

That second link looks like the tests are really nice to have.  I am  
not seeing where they come from, and how to get them.

While my grep is not working as I want it to:
	port contents mysql5 | grep -i opt.*\.pl
this is the only .pl file I get:
	/opt/local/lib/mysql5/bin/ndb_size.pl
Event this does not turn up a lot:
	port contents mysql5 | grep -i test


>> If I get a spare moment, I will look at the port file(s) and see if  
>> I can see what is happening.
>
> BTW -- I just noticed that the man page is mysqladmin, while the  
> binary is mysqladmin5.
>
> The difference in syntax between the two commands above is the "-p"  
> which appears to be logically correct at first, but unable
> to be parsed  because the [command-arg] is missing -- but with the  
> space following the "-p" causing the password prompt  AND
> acting as a delimiter -- one of those "unintended consequences",  
> followed by another [command] "password"
> ...  I hate unix for allowing such things - drives me nuts!
>
> "-p" being the command and the space being the command option,  
> followed by another command "password" an the new-password string,  
> which need not be quoted!
>
> --password[=password], -p[password]
>
>           The password to use when connecting to the server. If you  
> use the short option form (-p), you cannot have a
>           space between the option and the password. If you omit the  
> password value following the --password or -p option
>           on the command line, you are prompted for one.
>
> So if you were to change the syntax in the install output to be:
>
> /opt/local/lib/mysql5/bin/mysqladmin -u root -p password <new- 
> password>

I wish my memory was better, this whole -p fiasco has a mysql but  
ticket I reported against it many years back.

>> 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/
>
> I've been using Apple's Apache2 (2.2.13) and php (5.3.0)  
> installations, editing the config file to fire up php.

I would really suggest just going all MacPorts on the Apache and php  
side of things.  There was a bug in php5 a few months back.  I can say  
with a lot of confidence, MacPorts had a patch relesaed and ready for  
the world before any other people had a chance to get it up and  
running.  Sure, if you did it by hand, but for those not interested in  
that method, they were quick to react.  It was serious enough, I  
really did not want to go around to the hundreds of virtual hosts I  
had and add a connection reference to the mysql close command to  
prevent a crash.

> Will have to try phpMyAdmin -- just discovered it on the MAMP page.   
> I've led a sheltered life since I retired in 2002. :)

Some may disagree with me on this one.  For all the questions  
phpMyadmin opens as being something to install via ports, I say, do  
not install it via ports.  It is going to depend on Apache, which  
means you are getting that installed, and it is going to depend on  
php5, which means you are getting that installed.

phpMyAdmin is a littel heavy for a DB admin tool, but it works, and  
you can have it up and running in about 30 seconds after you download  
it.  1) download, 2) copy into a servable location 3) edit  
condig.sample.inc.php to config.php 4) add in random string and save  
5) load the url, login with root and your password you set when  
running the secure install script.

> Which reminds me, totally OT ... finding that MAMP WIKI page is like  
> pulling teeth -- there is no (obvious) link to it off the main  
> macports.org page... took "forever" to realize
> the organization of the site... I'm having the same issue with  
> mysql.org's on-line manual. Of course, now that I know where things  
> are, it's all "quite obvious."
> ... ghads its taking twice as long to install phpmyadmin than to  
> install mysql!
> ... hmm.. I notice that this installs perl 5.8.9, while Apple has  
> perl 5.10 darwin-thread-multi-2level.

Myself, and many others are pretty aware of the state of the MacPorts  
site, and have spoken at length about it, and how to improve it.  We  
never quite got past the part of, "whats next".  I have all the emails  
flagged, and there is a deeper more evil rooted reason it is important  
to deal with as well.

It should get fixed, if and when I have more time, I will do  
everything I can to help it be more navigable, as I tend to agree with  
you.

>> 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.
>
> The instructions in MAMP tell you to look for 3 lines... auth_type/ 
> user/password... only the first one exists -- auth_type.
> It doesn't mention editing the "secret key."

Those instructions are somewhat dated I think, phpMyAdmin I believe  
lets you chose cookie, auth, and some other form of authentication.   
It defaults to cookie now, so you need not edit that, just set
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE  
AUTH! */

mash the keyboard to whatever.  You seem to be running this locally,  
so there is not a heck of a lot of "security" you need to play.  If  
this was a production server with a public IP, I would play this  
entirely different.

> Based on the config file, I assume that you either create the secret  
> key and leave "cookie" as auth_type, or ADD the other two lines
> "user" and "password" if you change the auth_type to "config."

I never change a thing, you can just enter in a random string for the  
blowfish secret.

> Note: the "Documentation.html" file in phpmyadmin describes the  
> "cookie" vs "config" better than the MAMP page.

Maybe you could copy and update the wiki page for that portion?

> Interestingly, when phpMyAdmin first loaded, it complained it could  
> not load "mcrypt"
> [Cannot load mcrypt extension. Please check your PHP configuration.]

I think I mentioned that. You will sort of need to run `sudo port  
install php5-mcrypt`, though phpMyAdmin will run without it, and just  
a slight warning message to nag you at the bottom of the login screen.

> "port list active" does not show mycrypt (nothing shows as inactive).
>
> 	sudo port deps phpmyadmin
> 	Full Name: phpmyadmin @3.2.3
> 	Runtime Dependencies: php5-gd, php5-mbstring, php5-mcrypt, php5- 
> mysql, php5-zip
>
> Other than that, it runs correctly...I guess...
> 	[Additional features for working with linked tables have been  
> deactivated.....]
> At this point, I don't even know what a "linked table" is, so I'm  
> assuming I don't need to be concerned.

I do not use those, they can come in handy, but it is not something I  
would worry about.  You can follow the link and it will tell you what  
the linked tables are good for.

> At any rate, the particular application I was trying to activate --  
> lotroster -- now works with MySql.

Good news then.

> Again, I'm using Apple's Apache with macports php5, mysql and  
> phpmyadmin installations.

I had no idea that could even work to be honest. Good to know.

>>> Hope this helps.
>
> IMMENSELY !!!!
>
> Thank you!  And hopefully, my comments will help someone else in the  
> future.
>
> Without macports, I know personally from the early days of the  
> ARPAnet and the Internet, what a painful process installing complex  
> software is.


A ton of work went into where php5 is today.  ryandesign is the man  
who deserves a ton of that credit, as of course, the rest of the  
MacPorts guys, but his name is all over the php5 stuff.  `port info  
php5-* | grep -i ryandesign | wc -l`  so 37 total to be more precise.

Have a good weekend.
-- 
Scott * If you contact me off list replace talklists@ with scott@ *



More information about the macports-users mailing list