Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Tutorial: Installing Apache 2, PHP 5, MySQL 5, and phpMyAdmin on OS X

Tutorial: Installing Apache 2, PHP 5, MySQL 5, and phpMyAdmin on OS X
Thread Tools
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status: Offline
Reply With Quote
Dec 30, 2006, 04:34 PM
 
Tutorial: Installing Apache 2, PHP 5, MySQL 5, and phpMyAdmin on OS X

I struggled a little in figuring out how best to install Apache 2, PHP 5, and MySQL 5 (and phpMyAdmin) on OS X, given that Apache 1.3 and PHP 4 come preinstalled. This tutorial shows the steps that I took to get it all working, and while it may seem very basic to many of you, I figured that it might come in handy for some *NIX novices. Enjoy .

To the large portion of you who know far more than I do about this stuff: Please let me know if any of these steps are unnecessary or inappropriate!

---

We will be using MacPorts (previously DarwinPorts) to make the Apache 2, PHP 5, and MySQL 5 installations painless and easily upgradable.

1. Install MacPorts:

First, make sure you have Xcode installed. This will not work otherwise.

Note: This tutorial assumes that you want to compile MacPorts from source (and at the time it was written, this was the only way to obtain the latest version). You could
just as easily download a binary of MacPorts (if available) and scroll down to the "port sync" step inside the quoted block below.

Go to http://svn.macports.org/repository/macports/downloads and download the source for the latest version of MacPorts

Untar the source, and run the following command from within the newly created MacPorts (or DarwinPorts) directory, in order to place a MacPorts installation in /opt/local.

./configure && make && sudo make install

The following is taken from the MacPorts README:

This will place a standard DarwinPorts installation in /opt/local.
You should ensure that /opt/local/bin is in your PATH environment
variable, otherwise your shell will not be able to find the executables
that are installed by DarwinPorts.

If you are using a bourne shell (Panther and Tiger by default uses
bash) add the following line to your ~/.profile file. If the file
does not exist create it.

export PATH=/opt/local/bin:$PATH

If you are using a (t)csh shell (Jaguar) put the following line in
your ~/.cshrc file. If the file does not exist, create it. Your
changes will not take effect until you have opened a new shell.

set path=(/opt/local/bin $path)

Finally, you must download the port description files, the Portfiles:

port sync

If you want to update the Portfiles and the DarwinPorts infrastructure (base) run:

sudo port selfupdate
2.0. Install Apache 2:

To install the latest version of Apache 2, type the following:

sudo port install apache2

When that is done, you have to create a conf file (which you can edit to configure Apache 2):

sudo cp /opt/local/apache2/conf/httpd.conf.sample /opt/local/apache2/conf/httpd.conf

2.1. Preserve Old Apache Directories

Please perform the following steps if you wish for your "Sites" directories (i.e. /Users/user/Sites) to be accessed via http://your-server/~user, as is the case with Apache 1.3).

Open /opt/local/apache2/conf/httpd.conf, and change:

DocumentRoot "/opt/local/apache2/htdocs" to DocumentRoot "/Library/WebServer/Documents"
<Directory "/opt/local/apache2/htdocs"> to <Directory "/Library/WebServer/Documents">

Then, uncomment this line:

Include conf/extra/httpd-userdir.conf

2.2. Some Apache 2 extras

You may also want to uncomment the following lines in /opt/local/apache2/conf/httpd.conf:

Include conf/extra/httpd-autoindex.conf (Fancy directory listing)
Include conf/extra/httpd-default.conf (Some default settings)

2.3. Make Apache 2 access a little easier

Warning: Remember that OS X has a preinstalled version of Apache (1.3), which can turned on and off via "Personal Web Sharing" in Preferences, or via the "apachectl" command. The command points to that version of Apache, and not the one we are installing!

To make starting and stopping Apache 2 a little easier, we will construct an alias to Apache 2's apachectl. Add the following line to ~/.profile (Panther/Tiger) and restart the terminal to gain access to it:

alias apache2ctl='sudo /opt/local/apache2/bin/apachectl'

2.4. Start Apache 2 on reboot

Warning: When I perform the command below, I eventually get the following error: Workaround Bonjour: Unknown error: 0. I've read that this is harmless, but I really don't know for sure. I assume that everything ends up in proper order after a reboot.

To start Apache 2 now and whenever the system reboots, type the following:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist

2.5. Notes

We added "sudo" to the alias apache2ctl, so if prompted for a password, enter your root password.

To run Apache 2: apache2ctl start
To stop Apache 2: apache2ctl stop

---

3.0. Install MySQL 5:

Note: MySQL has a very nice binary installation of MySQL, so feel free to go ahead and use that instead of a port. I, however, like having my entire system (Apache 2, PHP 5, MySQL 5) installed together in the same fashion.

To install MySQL 5, we will first get the port. If you want MySQL 5 to run automatically after system startup, perform the following commands:

Warning: When I perform the launchctl command below, I eventually get the following error: Workaround Bonjour: Unknown error: 0. I've read that this is harmless, but I really don't know for sure. I assume that everything ends up in proper order after a reboot.

sudo port install mysql5 +server
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Otherwise, run the following:

sudo port install mysql5

3.1. Make MySQL 5 access a little easier

When done, you may want to add the following lines to ~/.profile (Panther/Tiger) and restart the Terminal to gain access to them:

Warning: You will need to type sudo -v before using mysqlstart, to avoid being prompted for a password in the background (thus preventing MySQL from starting).

alias mysqlstart='sudo mysqld_safe5 &'
alias mysqlstop='mysqladmin5 -u root -p shutdown' (The "-p" assumes that you will be using a password for root, which you of course should be)

3.2. Set up DB

Then, run the following to set up the database:

sudo -u mysql mysql_install_db5

You will now be able to use MySQL 5 (and you can use mysqlstart and mysqlstop for convenience).

I also recommend immediately adding a password to your root account:

mysqladmin -u root password [yourpw]

---

4.0. Install PHP 5:

(Make sure Apache 2 is stopped before proceeding.)

To install the latest version of PHP 5, type either:

sudo port install php5 +apache2 +mysql5 +pear (With PEAR) or sudo port install php5 +apache2 +mysql5 (Without PEAR)

When that is done, register PHP 5 with Apache 2:

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

And create a php.ini file (which you can edit to configure PHP 5):

cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini

Then open /opt/local/apache2/conf/httpd.conf again, and add this line:

Include conf/extras-conf/*.conf

You will probably want to register index.php with Apache 2 as a directory index page (automatically loaded as the directory index). If you would like to do this, also change:

DirectoryIndex index.html to DirectoryIndex index.html index.php

---

5.0. Install phpMyAdmin:

The port is not updated regularly, and installation is ridiculously easy for phpMyAdmin, so:

Go to phpMyAdmin > Downloads | MySQL Database Administration Tool | www.phpmyadmin.net and download it.

Next, untar the downloaded file. Rename the directory to "phpMyAdmin" and place it in your document root (/Library/WebServer/Documents if you have preserved the old Apache directories).

Create a php file called config.inc.php and place it in the root of the phpMyAdmin folder. This file will overwrite settings defined by phpMyAdmin/libraries/config.default.php. The following is my config.inc.php file. Some of the lines are not completely necessary, but I like readability and consistency:

Code:
<?php $cfg['blowfish_secret'] = '[A passphrase for internal use]'; $i = 0; $i++; $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['user'] = ''; $cfg['Servers'][$i]['password'] = ''; ?>
That's it! You should now be able to access it at http://your-server/phpMyAdmin. You can log in as root, add more users, create databases, etc.

---

I hope some fellow installation novices find this tutorial helpful .

Tavi
(Last edited by tavilach; Dec 31, 2006 at 02:06 AM. )
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
     
Fresh-Faced Recruit
Join Date: Dec 2006
Status: Offline
Reply With Quote
Jan 8, 2007, 08:54 AM
 
Thanks Tavlich. I've tried multiple different solutions for running an apache, SQL, PHP server on an iMac, including ApacheFriends, MAMP and Tenon's iTools. Although they are probably a little easier to install they don't afford the flexibiity that using ports provides, and the install went like a breeze anyway. I'll have to test drive it to make sure that it has all of the options that I currently need, but I believe so.

If I do need to build PHP with other options is that relatively easy to do?

Also, if I want a GUI front end to manage the server what would you recommend. I have used Webmin in the past without too many problems.

p.s. e-mail: sscotti@sscotti.com
     
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jan 8, 2007, 09:05 AM
 
I don't see why you need Apache2 when the built-in version works fine for most things. As for PHP5 and MySQL, both are available in precompiled .pkg forms (here and here) that take all of 2 minutes to install. That's what I did and it worked great for me.
     
Fresh-Faced Recruit
Join Date: Dec 2006
Status: Offline
Reply With Quote
Jan 8, 2007, 02:31 PM
 
Right. I've tried alot of those, like MAMP, XAMPP, the native OS X apache and the PHP packages from Entropy. Many of them did not support all of the features that I wanted/needed, in particular for Egroupware and some other PHP packages that I have.

Compiling your own affords a little more flexibility in terms of where things are placed and with adding additional features.

After you do it a couple of times (Using Darwin Ports or something like FINK) it is actually pretty easy.

I know that the MySQL package that is Opensource is very easy to install. I haven't tried the Entropy packages recently, I could go back and try that but I'm liking what I have now.
     
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Jan 9, 2007, 08:34 AM
 
Out of curiosity, what can Apache2 do that 1.3 or whatever can't?
     
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Jan 10, 2007, 03:13 AM
 
Panther user here.

I was wondering, what would be the easiest way to set up a local PHP/MYSQL environment? I've stumbled across this link, will that do it, or are there any particular pitfalls I have to look out for?

Just really taking baby steps, the idea is to set up a local SMF 1.1.1 forum that I can practice/experiment with for a month or two, before I get proper paid webhosting.

Thanks.
     
Fresh-Faced Recruit
Join Date: Jan 2007
Status: Offline
Reply With Quote
Jan 17, 2007, 06:07 PM
 
The entropy PHP install didn't work on my 10.4.8 Server. The process goes ok until the very end, and then it gives a 'Failed' error.
     
Fresh-Faced Recruit
Join Date: Jan 2007
Status: Offline
Reply With Quote
Jan 31, 2007, 05:46 PM
 
Thanks, good job. This article provided a good complement to this one I was following
James Duncan Davidson: Sandboxing Rails With MacPorts
especially cause i still needed php for my other apps
     
Fresh-Faced Recruit
Join Date: Feb 2007
Status: Offline
Reply With Quote
Feb 6, 2007, 05:32 PM
 
Hi,
first of all thanks for a great tutorial.
I already have mysql installed from the official distribution, and i just can't seem to get php5 to compile with mysql support, do I have to install the darwinports version or is there a way around?

thanks
     
Junior Member
Join Date: Mar 2005
Status: Offline
Reply With Quote
Feb 7, 2007, 07:05 AM
 
Great tutorial...I always found web development easier on the PC.
The Mac has come a long way on the web development side.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Feb 7, 2007, 05:18 PM
 
Hey Tavlich:

I used to be the port maintainer for phpMyAdmin, but I no longer have time to continue. Good to see MacPorts being used for this sort of thing though!

Have you ever experimented with having the Macports components co-exist with Apple's components so that you could use Apple's GUI to start/stop the server, and the OS X Server Server Admin GUI to configure Apache?
     
Fresh-Faced Recruit
Join Date: Feb 2007
Status: Offline
Reply With Quote
Feb 8, 2007, 05:21 PM
 
Feb 08, 2007
imac g5 tiger os4.8 2gb ram

Running mysql, php, zend ide for four years and never reinstalled them in less than a week.

Apple support had to initialize my hard drive after the system crashed, and I have spent the last 11 days trying to get back up and running. I have four external drives with 250gigs each from which I have tried to reconstruct the procedures used to reinstall my system which is mysql, php and the zend ide.
Most of my experience is MS and LINUX, I've used this imac for about a year.

I use jedit, bbedit, speed download and superduper every day for production and development.
I can and do work with the /usr directories.

I want to start with the apple install disk 1, then 2 installing every thing available. I then want to install mysql, php and the zend ide, backup the system as bootable so that I can avoid the mess I get into every time I screw up.

Right now I get nothing from entering "port sync" in step 1.0 of the tutorial, and I also tried "sudo port selfupdate" , both in /root and ~/home.
It always replies "bash: port: command not found".

What directory or folder do I place
"DarwinPorts-1.3.2(2).tar.gz",
"mysql-max-4.1.13-apple-darwin8.1.0-powerpc.dmg",
"Entropy-PHP-5.0.4-apache2-1.dmg",
"CompleteApache2-2.0.52.dmg.gz" and eventually
"ZendStudio-4_0_2.sit".

When I enter "sudo port install apache2" I assume it should be
"sudo port install CompleteApache2-2.0.52.dmg.gz" , is this correct?

Here's hoping some one can hold my hand on the simple and/or obvious.
Thanks

Dander
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Feb 13, 2007, 08:21 PM
 
Originally Posted by wataru View Post
Out of curiosity, what can Apache2 do that 1.3 or whatever can't?

Apache2 includes the ability to change its processing model to change how it handles requests. These are called MPMs. Unfortunately, no MPMs other than the default are terribly stable or secure, and the default is identical to the model used in Apache 1.3.x.

Apache 2 includes mod_dav and mod_ssl, and a bunch of improvements when run on Windows. It's what I recommend new installs use, but there is no absolutely huge reason to upgrade to it if you are happily running 1.3 with mod_dav and mod_ssl.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Feb 13, 2007, 08:23 PM
 
Originally Posted by dander View Post
Feb 08, 2007
imac g5 tiger os4.8 2gb ram

Running mysql, php, zend ide for four years and never reinstalled them in less than a week.

Apple support had to initialize my hard drive after the system crashed, and I have spent the last 11 days trying to get back up and running. I have four external drives with 250gigs each from which I have tried to reconstruct the procedures used to reinstall my system which is mysql, php and the zend ide.
Most of my experience is MS and LINUX, I've used this imac for about a year.

I use jedit, bbedit, speed download and superduper every day for production and development.
I can and do work with the /usr directories.

I want to start with the apple install disk 1, then 2 installing every thing available. I then want to install mysql, php and the zend ide, backup the system as bootable so that I can avoid the mess I get into every time I screw up.

Right now I get nothing from entering "port sync" in step 1.0 of the tutorial, and I also tried "sudo port selfupdate" , both in /root and ~/home.
It always replies "bash: port: command not found".

What directory or folder do I place
"DarwinPorts-1.3.2(2).tar.gz",
"mysql-max-4.1.13-apple-darwin8.1.0-powerpc.dmg",
"Entropy-PHP-5.0.4-apache2-1.dmg",
"CompleteApache2-2.0.52.dmg.gz" and eventually
"ZendStudio-4_0_2.sit".

When I enter "sudo port install apache2" I assume it should be
"sudo port install CompleteApache2-2.0.52.dmg.gz" , is this correct?

Here's hoping some one can hold my hand on the simple and/or obvious.
Thanks

Dander

MacPorts is simply a disk image install, you don't have to manually place any files anywhere to install it. If you haven't installed it, this is why the port command is not found for you.

All of the other binary installers are also not necessary if you use MacPorts, as the whole purpose of MacPorts is to automatically download and install these pieces for you.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Feb 13, 2007, 08:25 PM
 
Originally Posted by webmonkie View Post
Great tutorial...I always found web development easier on the PC.
The Mac has come a long way on the web development side.
Do you mean editing HTML, or in running a web server? If the former, there are a number of really useful things you can do in the Unix environment that work well when speaking to a Unix web server.
     
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Mar 27, 2007, 11:37 PM
 
About that warning you get after using launchd to have apache2 start up at boot - I have tried 3 times now, and when I do that, the system runs fine for a while, then every app rainbows out and I have to force a reboot into single user mode and remove the plist file to make it all work again.

Anyone have an idea what is wrong with the launchd plist file for apache that is causing the system to crash?

Thanks!
     
Senior User
Join Date: Mar 2007
Location: San Jose
Status: Offline
Reply With Quote
Mar 28, 2007, 03:15 PM
 
Maybe apache2 is spawning too many copies? Open Activity Monitor and see what's running when your system starts to hang.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Mar 28, 2007, 03:41 PM
 
Any log entries?
     
Fresh-Faced Recruit
Join Date: Mar 2007
Status: Offline
Reply With Quote
Mar 31, 2007, 01:29 PM
 
I tryed to install everything at one with the following command. But it gives me the same error as I got with this tutorial, why is this?

Maechis-iBook:~ markushacki$ sudo port install php5 +apache2 +mysql5
Password:
---> Configuring apr-util
Error: Target com.apple.configure returned: configure failure: shell =20
command "cd "/opt/local/var/db/dports/build/=20
_private_opt_local_var_db_dports_sources_rsync.rsy nc.darwinports.org_dpu=20=

pdate_dports_devel_apr-util/work/apr-util-1.2.8" && CPPFLAGS=3D-I/opt/=20=

local/include LDFLAGS=3D-L/opt/local/lib ./configure --prefix=3D/opt/=20
local --with-apr=3D/opt/local/bin/apr-1-config --with-expat=3D/opt/local =
=20
--with-iconv=3D/opt/local --with-berkeley-db=3D/opt/local/include:/opt/=20=

local/lib/db44 --without-mysql --without-pgsql" returned error 1
Command output: checking build system type... powerpc-apple-darwin8.9.0
checking host system type... powerpc-apple-darwin8.9.0
checking target system type... powerpc-apple-darwin8.9.0
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.2.8
checking for chosen layout... apr-util
Applying apr-util hints file rules for powerpc-apple-darwin8.9.0
checking for APR... configure: error: the --with-apr parameter is =20
incorrect. It must specify an install prefix, a build directory, or =20
an apr-config file.

Error: The following dependencies failed to build: apache2 apr-util pcre
Error: Status 1 encountered during processing.
Maechis-iBook:~ markushacki$

Does anybody know why this is?

Thanks in advance,
Markus
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Mar 31, 2007, 03:04 PM
 
When was the last time you did a port selfupdate?
     
Fresh-Faced Recruit
Join Date: Mar 2007
Status: Offline
Reply With Quote
Apr 1, 2007, 06:20 AM
 
It didnt help, I selfupdated it but It just had a little longer until it came to the same error while configuring apr-util...

Some ideas?
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Apr 1, 2007, 05:51 PM
 
Originally Posted by mhaecki View Post
It didnt help, I selfupdated it but It just had a little longer until it came to the same error while configuring apr-util...

Some ideas?

What OS X version are you running? Have you run al XCode updates?

If 10.4.x and yes, I'd suggest subscribing yourself to the Macports list and sharing your error there and/or contacting the port maintainer directly. You can determine the port maintainer by typing in:

port info apr-util
     
Fresh-Faced Recruit
Join Date: Apr 2007
Status: Offline
Reply With Quote
Apr 27, 2007, 04:03 PM
 
Originally Posted by dander View Post
Right now I get nothing from entering "port sync" in step 1.0 of the tutorial, and I also tried "sudo port selfupdate" , both in /root and ~/home.
It always replies "bash: port: command not found".
I just installed MacPorts on Panther and had the same issue. The installer writes a line (adding its directories to the path) into ".profile", however the default shell (bash) uses ".bash_profile"... so it ignores the .profile file. Just edit .bash_profile and add the line from .profile as the last line.

Jeff
     
Fresh-Faced Recruit
Join Date: May 2005
Status: Offline
Reply With Quote
Jul 10, 2007, 07:56 AM
 
Hi there,

thanks for this tutorial.

In 3.0. Install MySQL 5:
I choose to run
sudo port install mysql5
instead of the +server version and I stumbled upon permission problems afterwards trying to set up the database.

I followed the following steps and it solved the problem:
Tried to install server version: sudo port install mysql5 +server
encountered an error:
Activating mysql5 5.0.41_0+darwin_8+server
Error: Target com.apple.activate returned: Image error: Another version of this port (mysql5 @5.0.41_0+darwin_8) is already active.
Error: Status 1 encountered during processing.

uninstalled the port:
sudo port uninstall mysql5 @5.0.41_0+darwin_8
activated the port:
sudo port activate mysql5
set up db:
sudo -u mysql mysql_install_db5

instead of mysqladmin -u root password [yourpw]
I used mysqladmin5 -u root password [yourpw]

many thanks!

Henk
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 06:58 AM
 
I'm glad I found this but I'm having problems with mysql5.

I keep getting this error when running
sudo -u mysql mysql_install_db5

mkdir: /opt/local/var/db/mysql5: Permission denied
chmod: /opt/local/var/db/mysql5: No such file or directory
mkdir: /opt/local/var/db/mysql5: No such file or directory
chmod: /opt/local/var/db/mysql5/mysql: No such file or directory
mkdir: /opt/local/var/db/mysql5: No such file or directory
chmod: /opt/local/var/db/mysql5/test: No such file or directory
Installing MySQL system tables...
070919 20:24:06 [Warning] Can't create test file /opt/local/var/db/mysql5
/opt/local/libexec/mysqld: Can't change dir to '/opt/local/var/db/mysql5/' (Errcode: 2)
070919 20:24:06 [ERROR] Aborting

070919 20:24:06 [Note] /opt/local/libexec/mysqld: Shutdown complete

Installation of system tables failed!

Any idea what this means and how to get around it? I do have an older version of Mysql installed (done through darwinports before it was mac ports)
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 09:18 AM
 
It looks like user mysql doesn't have permission to do those things... Check to see who owns /opt/local/var/db/mysql5
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 07:26 PM
 
It seems to be owned by "mysql" and I have no access according to the finder.

I ran
sudo /opt/local/bin/mysql_install_db5 --user=mysql
and it seemed to install ok with a few warnings about being 'case sensitive' and "To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system"
It would be nice if they told me *where* exactly on my system that was

The final line told me to set a password. I tried and got:
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

hmmmm. Anyone have any ideas?
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 07:42 PM
 
This is because MySQL needs to be running in order to set the admin password. Do a:

sudo launchctl list

Do you see any MySQL entries there? What happens when you so a

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

If you see an error message, chances are the startup script is not in /Library/LaunchDaemons and therefore wasn't installed. Did you install MySQL with the +server variant option?

sudo port install mysql5 +server

If you didn't, you installed the MySQL client. You'll need to do a:

sudo port uninstall mysql5
sudo port install mysql5 +server

Then you should be able to startup the MySQL server.
(Last edited by besson3c; Sep 19, 2007 at 07:48 PM. )
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 07:50 PM
 
I see:
com.apple.dashboard.advisory.fetch
com.apple.KernelEventAgent
com.apple.mDNSResponder
com.apple.nibindd
com.apple.periodic-daily
com.apple.periodic-monthly
com.apple.periodic-weekly
com.apple.portmap
com.apple.syslogd
com.apple.usbmuxd
com.vix.cron
org.postfix.master
org.xinetd.xinetd
org.macports.apache2

When I do sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
It tells me "nothing to load"

But I certainly installed the server and mysql5.

I just tried "mysqladmin5 -u root password "mynewpassword'
and got
mysqladmin5: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

But I'm sure I'm using the password I set up with it.

So it seems to be running, just not in conjunction with macports.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 07:51 PM
 
What do you see when you do this:

port installed | grep mysql
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 07:52 PM
 
Oh I tried
sudo port uninstall mysql5
and got
sudo port uninstall mysql5---> The following versions of mysql5 are currently installed:
---> mysql5 @5.0.45_3+darwin_8
---> mysql5 @5.0.45_3+darwin_8+server (active)
Error: port uninstall failed: Registry error: Please specify the full version as recorded in the port registry.

So again, it seems to be there...
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 07:53 PM
 
Originally Posted by besson3c View Post
What do you see when you do this:

port installed | grep mysql
looks like all my old junk:
mysql5 @5.0.45_3+darwin_8
mysql5 @5.0.45_3+darwin_8+server (active)
php4 @4.4.0_0+apache+macosx+mysql4
php4 @4.4.0_0+apache+macosx+mysql4+xslt
phpmyadmin @2.6.1-pl2_0+apache+mysql4+php4
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 07:54 PM
 
ls /Library/LaunchDaemons

and

ps aux | grep mysql
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 07:56 PM
 
Originally Posted by besson3c View Post
ls /Library/LaunchDaemons
org.macports.apache2.plist
and

ps aux | grep mysql
org.macports.apache2.plist

and

mysql 24792 0.0 -0.1 40740 2608 ?? SNs 8:47AM 0:00.23 /System/Library/Framework
mysql 24914 0.0 -0.7 65556 14604 p1- R 9:06AM 0:01.04 /opt/local/libexec/mysqld
matty 25026 0.0 -0.0 27812 4 p1 R+ 9:26AM 0:00.00 grep mysql
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 08:04 PM
 
So some version of MySQL is running, but curiously you don't seem to have the launchd startup script. Was your copy of Macports ever on a 10.3 system? The mysql.server script is the script that is included on 10.3 systems. Are you running the latest copy of both XCode, and have you run all of your developer tools software updates?

Any theories as to why MacPorts thinks your system is a 10.3 system?
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 08:09 PM
 
Yes, latest versions of xcode and dev tools. Nope, never on a 10.3 system, but I did have darwinports installed.

Weirdly I can now type
mysql5 -u root -p

and see the basic install (Test/Mysql/Information Schema) and I can move around and use dbs and show tables, so its working.

not sure where that leaves me. Is it even possible to rm everything to do with macports and start again? That would take ages.
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 08:54 PM
 
So any way to delete that old mysql? The apache install and config outlined here went beautifully, just seems there is a glitch in my MySQL install - anyone have a tip on how to rid all versions/links/mysqld/mysql.server scripts once and for all?

Thanks!
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 19, 2007, 09:17 PM
 
sudo uninstall mysql5 @5.0.45_3+darwin_8+server
sudo uninstall mysql5
update your ports tree, reinstall
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 11:42 PM
 
Just about to try it - but how do I update my ports tree? What's the syntax/cmnd for that?

Thanks.
(Last edited by speaktomenow; Sep 19, 2007 at 11:43 PM. (Reason:typo!))
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 19, 2007, 11:45 PM
 
erm justr tried it and got:
sudo: uninstall: command not found

Then tried
sudo port uninstall mysql5 @5.0.45_3+darwin_8+server
---> Unable to uninstall mysql5 5.0.45_3+darwin_8+server, the following ports depend on it:
---> php5
Error: port uninstall failed: Please uninstall the ports that depend on mysql5 first.

But php5 is running so nicely - anyway around doing that? I find myself in a loop that won't let me uninstall mysql because php needs it or php because mysql needs it.

PS run selfupdate:

Downloaded MacPorts base version 1.520
The MacPorts installation is not outdated and so was not updated
DEBUG: Setting ownership to root
selfupdate done!
(Last edited by speaktomenow; Sep 19, 2007 at 11:52 PM. (Reason:added more info))
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 20, 2007, 12:02 AM
 
Originally Posted by speaktomenow View Post
Just about to try it - but how do I update my ports tree? What's the syntax/cmnd for that?

Thanks.
sudo port -v selfupdate
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 20, 2007, 12:04 AM
 
Originally Posted by speaktomenow View Post
erm justr tried it and got:
sudo: uninstall: command not found

Then tried
sudo port uninstall mysql5 @5.0.45_3+darwin_8+server
---> Unable to uninstall mysql5 5.0.45_3+darwin_8+server, the following ports depend on it:
---> php5
Error: port uninstall failed: Please uninstall the ports that depend on mysql5 first.

But php5 is running so nicely - anyway around doing that? I find myself in a loop that won't let me uninstall mysql because php needs it or php because mysql needs it.

PS run selfupdate:

Downloaded MacPorts base version 1.520
The MacPorts installation is not outdated and so was not updated
DEBUG: Setting ownership to root
selfupdate done!
You need to force an uninstall of mysql:

sudo port -f uninstall mysql5 @5.0.45_3+darwin_8+server
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 20, 2007, 12:09 AM
 
Yep I figured that and have done it, thanks.
Currently I am running sudo port install mysql5 +server as per the instructions at the top of this page and its up to "Configuring mysql5"

Once that's done do I run
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist (as per instructions)
or
sudo port install mysql5
?
Because previously it kept telling me there was nothing to load at mysql5.plist

Thanks - getting there!
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 20, 2007, 12:21 AM
 
speaktomenow: you really should try to understand what it is that we are doing. Please let me know if you have any questions.

The org.macports.mysql5.plist is Tiger's launchd configuration for MySQL that starts and keeps MySQL running. You might want to do some reading into launchd. This isn't a Unix or MacPorts thing, this is an OS X thing.

Your problem was that your install did not install the launchd configuration, and instead gave you instructions for starting MySQL via systemstarter, an OS X utility in 10.3 for starting and stopping services. The mysql.server script was a systemstarter script.

So, if after this installation you should now have your launchd configuration for MySQL.



Edit: curiously, it looks like the MySQL 5 port is no longer using launchd for some reason... It used to, I swear! The startup script is now installed into:

/opt/local/share/mysql5/mysql/mysql.server

Do you have this file installed? If so, try running a:

sudo /opt/local/share/mysql5/mysql/mysql.server stop
sudo /opt/local/share/mysql5/mysql/mysql.server start

sorry for sending you on a wild goose chase.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 20, 2007, 12:23 AM
 
To setup your database, try a:

sudo /opt/local/bin/mysql_install_db5
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 20, 2007, 12:54 AM
 
Cool. I missed the 'plist' completely which is kind of a giveaway that it's OSX (d'oh!)

But all is good, has gone in and I've run
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
and got the same bonjour error message as above in the tutorial, but no other "not found" errors" and the tables have been built.

So just to confirm the next steps in order should be:
1 - start mysql with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
2 - run:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
(are the quotes required? - not sure of my syntax here - sorry kind of a n00b question I know)

Then I'm done...
and I should be good to go
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Online
Reply With Quote
Sep 20, 2007, 03:39 AM
 
AFAIK, the current MacPorts MySQL 5 will not install a launchd configuration file for you. Am I mistaken? If so, your step 1 should be unnecessary since loading the config into launchd will start up MySQL.

Quotes are required, I believe.
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 20, 2007, 04:04 AM
 
hmmm. Permissions/passwords seems to be my last hurdle:

I went to step 2 above:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'

and got

/opt/local/lib/mysql5/bin/mysqladmin -u root password '*****'
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

So I tried step one:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
and got
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

I tried to open the mysql5 folder in the finder to see if it exists but guess what? Not enough permissions.

Not sure what's going on with the password/permisssions but its feeling close now.
     
Fresh-Faced Recruit
Join Date: Sep 2007
Status: Offline
Reply With Quote
Sep 20, 2007, 05:07 AM
 
OK so after much googling and frustration I found this link on OSXFAQ
I did a restart and bingo - now mysqld.sock does exist!

So of course now I can log on to MySQL5 - yippe

Sheesh, that was easy....Who thinks to reboot? I go months without rebooting my mac

Anyway, next task is to redo all this to get sablotron installed. I installed with xslt but now have to redo with +sablotron.

Suffering major exhaustion, so will be leaving everything until tomorrow.

Thanks though!
     
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Nov 13, 2007, 11:42 PM
 
Any updates on MySQL for Leopard? The binary they have on mysql.com doesn't fully work. The pref pane doesn't work, etc.
     
 
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 05:52 PM.
All contents of these forums © 1995-2009 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.4 © 2000-2009, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2