67 comments thus far...

[...] mentioned in my previous article I’d show a couple of MySQL Administrator tricks so here goes. Many programmers like to use [...]

From: MySQL Administrator on Mac OSX Leopard: A Few Tips and Tricks · superfancy on 08.23.2008

Stevie,
I feel like such a goofball, but I can’t get this to work. I’ve tried so many times, it’s crazy. No matter what I do, I get to the virtual hosting part and get a “can’t find the server” or “can’t find local host” every time. I updated to Leopard, so I’m wondering could it be older apache files are messing me up? I also have mysql already installed, though its not running yet cause I haven’t been able to get beyond running virtual hosts. Help. I’m wondering if anyone else has this problem and if you’ve come across a solution? Thank you for this post, the descriptions are fantastic.
April

From: April on 09.22.2008

Hi April. Thanks for stopping by. I would recommend getting MySQL up and running first and then deal with the Virtual Hosts. When I was setting up my G5 at work I had a really difficult time getting the Virtual Hosts to work as it had previously been running Tiger. I had no such issues on my MacBook Pro though.

An important detail to not overlook is anytime you make any changes to Apache files, remember to restart Apache to activate the changes. It’s an easy thing to forget and the root of many frustrations.

If you have any specific questions, feel free to use my contact form and I’ll do my best to help you out…

From: Stevie on 09.22.2008

Thanks a lot for your awesome work !

Your comments were indeed very helpful

From: leopardnewbie on 11.11.2008

Thanks… glad people are getting some use out of it. I had a tricky time getting things all squared away so I’m more than happy to share. Thanks for stopping by…

From: Stevie on 11.11.2008

Hi Steve,

Could you sense what could be wrong, when my MySql does not connect after I restarted my MBP.

I did use MySql Administrator which you had described above. The first time the connection went thru, used the MySQl Query browser to work on Northwind schema and got my php stuff to work.

Now I get Connection Error : Could not connect to MySQL instance at localhost.
Error:Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’(2)(code 2002)

I tried it thru terminal, it does get the same error.

Pinging the Host is not successful either

Would very much appreciate your trouble shooting, yourself being a pro…

Thanks

From: leopardnewbie on 11.13.2008

Some add-ons to the troubleshooting situation requested above :

I did not complete the steps you had mentioned in

” MySQL Administrator on Mac OSX Leopard: A Few Tips and Tricks · superfancy on 08.23.2008″

like

1. Setting password for root
2. Adding a new mysql user
3. creating a new db
4. assigning privileges to user

Would these activities influence for the connection error?

Thanks for any suggestions

From: leopardnewbie on 11.13.2008

Hey. Well my first question is, did you install the MySQL Preference Pane? If so, head over to System Preferences and at the bottom under Other, click on MySQL. From there you’ll be able start MySQL.

In Jeremy Keith’s article I link to above, he set’s up a Terminal command that automatically starts MySQL when your Mac boots up.

I just start MySQL manually because I don’t use it everyday.

Hope this at least gets you on the right track…

From: Stevie on 11.13.2008

I would concentrate on getting MySQL up and running as you won’t be able to add any users till it successfully starts up…

From: Stevie on 11.13.2008

I get the error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR! Manager of pid-file quit without updating file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
when I try to start the mysql server thru the terminal like:

sudo /usr/local/mysql/support-files/mysql.server start

Meanwhile in an attempt to view the data folder in mysql, I issued the command
chown 755 to that folder, which I guess is not right. How do I revoke it.

Thanks again for your time

From: leopardnewbie on 11.13.2008

Whoa… never seen that error before! I am unsure how to revoke the above command. There’s a syntax for doing those types of Terminal commands but I can’t remember off the top of my head.

Man sounds like you’re having some problems. I struggled too getting this stuff working in previous attempts in the past. I spent many hours and days googling and doing things by trial and error.

From: Stevie on 11.13.2008

Thanks a lot for your comments… I am all set to troubleshooting…

From: leopardnewbie on 11.13.2008

BTW, to revoke the chown 755 issued earlier to the mysql/data folder , I used the command:

sudo chown -R root:wheel data

which changed the owner to root again

…just in case it would be useful to someone reading this

From: leopardnewbie on 11.13.2008

Hi Stevie,

So I finally got my mysql running..

I dumped the previous version of mysql and re installed again.

Your site surely gives a lot of insight to any newbie like me… I must reiterate…

Thanks

From: leopardnewbie on 11.13.2008

Excellent. I was going to recommend reinstalling as a last resort. I know that worked for me on my G5 tower at work which used to have Tiger on it. Cool man glad you got it working… now you can finally do some real work :)

From: Stevie on 11.13.2008

hi leopardnewbie,
I have the same error (ERROR! Manager of pid-file quit without updating file), did found a solution for this?

From: cosmoanut on 12.01.2008

Hi Stevie

Thumbs up for a very helpful site.

I have stumbled across one problem which is to do with
“create a my.conf file in your text editor and save it in /etc/my.cnf with the following code:”
I don’t seem to have the my.cnf folder and when tying to make a new folder to save the my.conf file in I get the message that the /etc folder is read only

I’m a complete newbie so any pointers would be great.

From: Scott on 12.11.2008

Hey Scott. Thanks for the nice words. Here’s something you can try…

Go into the root directory of your Mac and find the private folder. There you’ll find the etc folder. Right-click on it and click Get Info and verify that the system has Read & Write permissions. If it has both then you should be able to create a my.cnf file…

From: Stevie on 12.11.2008

Stevie, just wanted to say thanks for the detailed guide. Managed to get all the way up to the MySQL install, but couldn’t find good documentation on what to do. This worked like a charm. Definitely appreciate it!

From: Kevin on 12.16.2008

Kevin… thanks for dropping by. My main inspiration for writing this article was the lack of any MySQL setup tutorials pertaining to OSX. Glad you found it useful!

From: Stevie on 12.17.2008

Stevie,
Thanks so much for putting this stuff on the web. It is very straightforward. Unfortnately, I am experiencing the same difficulty that April did on September 22nd. Please advise.
Sincerely,
John

From: John on 12.17.2008

Fantastic!!
The best and the easiest method so far and i have looked everywhere. This worked like a charm.

Cheers :)

From: spiftic on 12.20.2008

with regard for this error: (ERROR! Manager of pid-file quit without updating file)

try this:

sudo chown _mysql /var/mysql

From: JC on 01.16.2009

Just so it’s clear sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock doesn’t move the mysql.sock file it just creates a sym link to it. That is all that is needed to get mysql going with php on leopard.

From: Darren on 01.20.2009

Darren… that’s a great point. One that I didn’t make clear in my article. Thanks…

From: Stevie on 01.20.2009

Stevie, I still need a little clarification please. From your following instructions.

“create a my.conf file in your text editor and save it in /etc/my.cnf with the following code:”

Am I creating a my.conf or a my.cnf file? and am I just installing it in the /etc/ folder (i.e. /etc/my.conf – or – /etc/my.cnf)? A post above spoke about a my.cnf folder (i.e. /etc/my.cnf/my.cnf)

The reason I ask is that when I create a my.cnf file and copy it to the /etc/ folder, mySQL stops running, but when I create a my.conf file with the same information in it mySQL continues to run.

Is there a reason why this would be the case?

This is the code I used:

[client]
socket = /var/mysql/mysql.sock

[mysqld]
socket = /var/mysql/mysql.sock

What exactly does this file do?

Thanks. =)

From: Chris V on 01.28.2009

Chris:

Yeah the file is just called my.cnf and is placed in the /etc folder. At least this is how it is on my machine. My experiences with setting up PHP and MySQL in the past have all been subtly different, but this is what worked for me.

Basically and too the best of my knowledge, all the my.cnf does is tell PHP where the to look for the MySQL connection.

Hope this helps…

From: Stevie on 01.28.2009

Stevie,

Thanks for the response. I appreciate the time you took. =)

From: Chris V on 01.28.2009

Very well written doc. Thanks, it helped a lot!

From: Eduardo on 03.18.2009

A very useful document.

A couple of things to note that gave me trouble in my setup:

1) In the “Testing PHP section” you have the line:

My computer didn’t like it until I changed it to:

(deleted the first space) and then everything was fine.

2) Once website sharing was enabled, I still didn’t have access to my personal website, despite everything looking fine. Eventually tracked the problem down to permission on my home directory (eg. /Users/ ) being wrong – they were 700 instead of 755. Once that was fixed, I could move on.

From: Mike on 04.21.2009

@Mike Wordpress for some reason adds a space between the opening php bracket and the question mark. Trying to track down the issue but that is a good point nonetheless.

I occasionally have permissions issues as well.

From: Stevie on 04.21.2009

I removed the syntax highlighter on phpinfo(); for better cut and paste action…

From: Stevie on 04.21.2009

Steve,
In the part of your article where you talk about virtual hosts the first line of the code segment should read:

Note the /*/ at the end of the path. That might have been the problem for the people that couldn’t make their virtual hosts work.
Regards,
Werner

From: werner on 04.28.2009

Well it didn’t print the line of code:

“”

From: werner on 04.28.2009

@werner: Try wrapping the line in a code tag.

From: Stevie on 04.28.2009

Ah, good ol’ Wordpress…

From: werner on 04.28.2009

@werner Yeah WP drives me nuts some times. I will email you…

From: Stevie on 04.28.2009

Steve,
the comment box doesn’t take the code tage either. I mean first line with the path “/Users/StevieBenge/Sites”. The path sould be “/Users/StevieBenge/Sites/*/”
Werner

ps if this doesn’t work send me your email and I’ll send you a PM

From: werner on 04.28.2009

@werner Thanks for clearing this up. I will edit the article to reflect this.

From: Stevie on 04.28.2009

Stevie,
You are welcome, I just went to the same discovery reading – I don’t know how many – mostly incomplete “tutorials” about this on the web. My angle is that I develop Joomla websites and I am setting up my Mac for debugging with Eclipse and XDebug. I am about to publish a blog when I came accross your article. It confirmed what I had seen except that I don’t have to do anything with the mysql socket. After I installed mysql it worked…
Anyway, good luck with your web design biz. Check out my blog if you have a minute… http://www.theglinkacompany.com/blog

From: werner on 04.28.2009

@werner: Thanks for the nice words. I use WP and Drupal for most sites that I do, but I am curious about Joomla. I will definitely check out your blog. Thanks!

From: Stevie on 04.28.2009

[...] Setting up PHP, MySQL, and Apache in Mac OSX Leopard [...]

From: Yes, yes it’s been a while… · superfancy on 05.08.2009

[...] here to see the original: Setting up PHP, MySQL, and Apache in Mac OSX Leopard · superfancy Share and [...]

From: Setting up PHP, MySQL, and Apache in Mac OSX Leopard · superfancy on 05.11.2009

Hello. I’m having a problem. I’m so used to setting up PHP and what not on Windows machines that I’m having trouble on my macbook pro. This is my first time using a macbook pro by the way.

Anyway, after doing the initial test to get PHP and Aapache up and running everything was initially fine. I then followed the part about sharing the web services and adding the line to the hosts file. I got all the way to making the test.php file and putting it in my Sites folder and that’s where I’m stuck.

Every time I try to go to http://localhost/test.php all that shows up is that actual text of the file test.php. It doesn’t run the phpinfo() function. It’s almost as if php isn’t running.

Any suggestions because I’m at a complete loss.

From: Sean on 06.05.2009

Hey, I figured out my problem. It turns out I have a few things to learn about editing in Dreamweaver. I’m used to my IDE that I use in Windows. When you create a new php file in it you start out with a blank page, the way it should be.

However when I opened up Dreamweaver on my macbook pro and said to create a new php file it turns out that I was initially in live view mode but didn’t realize it. When I sent to split view mode I saw that even though I said to create a new blank php file Dreameweaver actually created an html template file and so the phpinfo() function I was trying to execute was simply being output to the screen. Once I got rid of all of the html code everything ran just fine.

From: Sean on 06.05.2009

Hi Stevie,
a quick thanks. Your instructions were right on the nail, especially for a first time user like me so I am happily up and running now.
Cheers,
Gary

From: Gary on 06.06.2009

Hello all,

I’ve got multiple problems with running both virtual hosts and mysql. Let me bother you with it, as some of you may have already gone through it.. :
1. After following all steps about VH, I have a permission problems and error 403.
2. After downloading all files needed to work with mysql I cannot connect to the server neither through mysql preferences in system preferences nor through terminal. In both cases my Mac is working through my command for about 1M, and then nothing happens..

I am the only owner/user of my mac, so I assume I have access to all files and permission to display them.

I hope somebody can help me with it.

Best,
Lucas

From: Lucas on 06.19.2009

This article was EXTREMELY helpful. However, I was unable to make mysql work when I moved the mysql.sock file to /var/mysql/mysql.sock

I had to move the file back to /tmp/mysql.sock

even after changing the my.cnf file.

I’m interested in any ideas as to why this is.

Martha

From: Martha on 06.22.2009

@Lucas: Make sure you restart Apache before accessing your virtual hosts. I’m unsure about the second problem you’re having. Sounds like MySQL could be corrupted perhaps?

@Martha: Did you restart MySQL after you moved mysql.sock to /var/mysql/mysql.sock? Off the top of my head that would seem to be a likely culprit.

From: Stevie on 06.22.2009

I attempted to restart MySQL after I moved mysql.sock to /var/mysql/mysql.sock and it would not start. Do you suggest that I try moving it again and restarting again?

Please advise and thank you.

From: Martha on 06.23.2009

@Martha: I would give that a shot yeah. Are you running a Mac with and Intel or PowerPC processor?

From: Stevie on 06.23.2009

I’m running MAC with Intel processor

Ok. Yesterday, I moved mysql.sock to /var/mysql/mysql.sock and I changed the my.cnf file but mysql failed to start after the move. I moved mysql.sock back to /tmp/mysql and still, no luck. So I reinstalled Mysql. Mysql was running this morning and php was running until I moved mysql.sock back to /var/mysql/mysql.sock again at this point mysql failed to start. I moved the mysql.sock file back to /tmp/mysql.sock and everything is working except… my ability to access a database.

Before I moved the mysql.sock file I did attempt to edit php.ini and the socket path there but this file is a read only even when I use the sudo command.

any thoughts?

From: Martha on 06.23.2009

@Martha: Ok sounds like mysql.sock wants to be in tmp/mysql for some reason. This is interesting because on the PowerPC machine I use at work it is like that too. Strange. I’m going to take a stab in the dark and recommend that check if you have rights assigned to the MySQL account trying to connect to the database. I wrote an article detailing how to assign privileges and working with MySQL Administrator. Check it out and see if that helps…

http://superfancy.net/coding/mysql-administrator-on-mac-osx-leopard-tips-and-tricks/

From: Stevie on 06.23.2009

Extremely helpful. You included everything into one place, made it very simple to understand. I thank you deeply for this great info. Had it set up in 30 min!

From: Brian on 06.23.2009

Thanks for the link! I think I”m getting closer:

I was unable to start via the MySQL administrator but when I start either through the command line
sudo /usr/local/mysql/support-files/mysql.server start or through the system preferences pane and then I go into the system administrator the detail shows:

User: root
Host: localhost
Socket: /tmp/mysql.sock

Server info:
MYSQL Version: mySQL 5.1.35-log via socket
Network name: localhost
IP: 127.0.0.1

Client information

Version: MySQL Client Version 5.1.8
Network name: mvanorshoven.local
IP: 192.168.1.108
Operating System: Darwin 9.7.0

ok. so now when I’m in the MySQL Administrator world I added a password to root user, I added myself as a user and when I clicked on catalogs, the database that I had created along with the tables are there! this is exciting.

Uh oh, now when I go back to the Schema Privileges page and attempt to expand the user ‘martha’, the only item below it is %. However, below root I have localhost, root@mvanorshoven.local and root@127.0.0.1.

Ok, I highlighted ‘martha’ and then added ‘localhost’ (two buttons next to the sillhouette icons) and I added 127.0.0.1 as well as mvanorshoven.local.

So that all looks great but still, when I’m in firefox and run the following php file:
<?php
$dbhost='localhost:/tmp/mysql.sock';
$dbuser='mvanorshoven';
'$dbpass=' ';

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connect to mysql');
print "Connected to MySQL”;

$dbname=’nativeplants’;
mysql_select_db($dbname) or die (‘Unable to select database’);
?>

The message I receive is:
Connected to MySQL
Unable to select database

So where to next? I did put passwords into the MySQL admin screen but when I entered that password in the $dbpass field the error was:
Access denied for user ‘mvanorshoven’@'localhost’ (using password: YES)…

From: Martha on 06.23.2009

This article, http://superfancy.net/coding/mysql-administrator-on-mac-osx-leopard-tips-and-tricks/, was helpful!

Ok. So I did set up MySQL administrator but was unable to start the server via the administrator. Maybe that’s not it’s function. I am able to start the server via the System Preferences Pane as well as from the command line.

I was also able to access my database, nativeplants, as well as it’s individual tables, commonname and grasstable, via the MySQL administrator. And… I made the connection without needing to put in a password for root, even though I set up a root password through the MySQL administrator when I edited the account.

I am still baffled though, as to why the following file:

<?php
$dbhost='localhost:/tmp/mysql.sock';
$dbuser='mvanorshoven';
$dbpass='';

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecto to mysql');
print "Connected to MySQL “;

$dbname=’nativeplants’;
mysql_select_db($dbname) or die (‘Unable to select database’);
?>

produces the following message
Connected to MySQL
Unable to select database

I’m very new at this so I’m wondering if I am connecting to the database but erroneously printing out the wrong error messages or visa versa.

From: Martha on 06.24.2009

Thanks very much! I’ve just moved over from Tiger to Leopard and was having real issues getting virtual hosting to work. Your instructions on editing the my.conf file have done the trick and solved my 403 error. Much appreciated.

From: Ruth on 06.25.2009

Thank you for this excellent, detailed step-by-step guide.

From: The Pedlar on 07.05.2009

This is an excellent tutorial on how to setup PHP, MYSQL, and APACHE on a Mac. Thank you so much for this!! :)

From: Caleb on 07.16.2009

Thanks so much for the tutorial. I had to modify the php.ini file, to change MySQL to /tmp/mysql.sock.

I also changed the directories in my.cnf to /tmp/mysql.sock so mine looked like:
[client]
socket = /tmp/mysql.sock

[mysqld]
socket = /tmp/mysql.sock

Without these changes, I was getting an error everytime I tried to start MySQL

From: Ashley on 07.18.2009

In some error messages from Apache, it asks the user to contact the system administrator and shows an email address.

Do you know how to change the email address that is shown in this error message from Apache? Where does it get it from?

From: Arjen on 11.08.2009

@Arjen: Thanks for visiting. If you look on or around line 151 in your httpd.conf file, you’ll see:

ServerAdmin you@example.com

Change the example email address to your desired address, then restart apache. I think that should do it.

From: Stevie on 11.08.2009

[...] Setting up PHP, MySQL, and Apache in Mac OSX Leopard [...]

From: I’m Still Here… · superfancy on 11.09.2009

Hello Stevie,

Im not a programmer so this question may be stupid, but anyway. All these settings have to be done using the root user when logging into my Mac? or my Administrator user?
Because if Im logged as Administrator I can’t edit the httpd.conf file.

Thanks for your help

From: Augusto on 11.10.2009

@Augusto: Yes that is correct… you need to be logged in as an Administrator to make changes to system files.

From: Stevie on 11.10.2009

Hi Again Stevie,

Thanks for your answer…

Im logged in as Administrator and still cannot edit the httpd.conf file. How can I give the Administrator account the rights to write/edit this file?

Im sorry, but besides that Im not a programmer I am new to Mac. :)

Thanks Again.

From: Augusto on 11.11.2009

[...] followed the instructions on http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/ I saved a copy of this as “Setting up PHP, MySQL, and Apache in Mac OSX Leopard · [...]

From: Configured my mac as a testing web host « Littlegreymouse's Blog on 01.18.2010

Anything to add?


Comments RSS