Need help activating Macports install of MySQL5 on Snow Leopard

William H. Magill magill at mcgillsociety.org
Fri Dec 18 22:21:52 PST 2009


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"

> 
>> 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... :)

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

> 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.

>> 	###########################################################
>> 	# 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?

Yes I did get it, and started the daemon.

> 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

Now I see what you mean about the difference between client and server install ... !

> 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


>> =====================================================================================
>> 
>> 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.

I know the feeling, my brain is beginning to hurt...

> 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>

It is the same syntax as the MAMP command example.

> =====================================================================================
>> 
>> 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/

I've been using Apple's Apache2 (2.2.13) and php (5.3.0) installations, editing the config file to fire up php.

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

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.


> 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."

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."

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

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

"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.

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

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


>> 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.

T.T.F.N.
William H. Magill
# Flat-panel iMac (2.1) [800MHz - Super Drive - 768 Meg] OS X 10.4.11 
# iMac6,1 Core 2 Duo [2.16GHz - 3 GB 667] OS X 10.6.2
# MacBook Pro4.1 Core 2 Duo [2.5GHz - 4GB 667] OS X 10.6.2
# Mac mini Core Duo [1.66 Ghz - 2 GB 667]OS X 10.6.2
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg] Tru64 5.1a 
# XP1000 [Alpha 21264-3 (EV6) - 256 meg] FreeBSD 5.3
# XP1000 [Alpha 21264-A (EV6-7) - 256 meg] FreeBSD 5.3
magill at mcgillsociety.org
magill at mac.com
whmagill at gmail.com










More information about the macports-users mailing list