mySQL on mac (10.6.6) -- simple question

I just installed mySQL server on my mac (10.6.6); to set up followed instructions here:
Installing MySQL on Mac OS X « Thoughts by Techxplorer

am trying to connect with PHP, connection is failing, and have a feeling I have wrong server/host param…

$dbhost = “localhost:3306”;
$dbuser = “root”;
$dbpass = “<pswd>”;
$dbname = “mydb”;
$dbconn = mysql_connect($dbhost,$dbuser,$dbpass) or die(“Could not connect”);
print “Connected successfully<br>”;

tried with and without port… is ‘localhost’ correct for host? (in windows it would be, not sure about on the mac/unix…)

thank you…

tried to edit, didn’t work… now don’t see ‘edit’ link…

url I meant to post was:
Installing MySQL on Mac OS X « Thoughts by Techxplorer

SOLVED – it’s, instead of localhost (connected from JSP/Tomcat now too… in there can be either localhost or; but in PHP it has to be the IP addresss…)

(and, funny, don’t need port (localhost:3306) like you do in windows… )

Doesn’t need to be the IP address, it can be simply localhost you likely don’t need the port number.

I’ve always used localhost in all the scripts I’ve written in PHP.

weird… I tried again with ‘localhost’ in PHP before posting my last response… it didn’t work… only works with the IP address…

thank you…

In mysql client run the following:

USE mysql;
SELECT user, host FROM user;

does it show or localhost under the host column for the user you’ve logged in with?

Just realizing your setup may have the former rather than latter. haven’t set up a mac in a while.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user, host from user;
| user | host                               |
| root |                          |
| root | ::1                                |
|      | <myName>s-MacBook-Pro.local        |
| root | <myName>s-MacBook-Pro.local        |
| root | localhost                          |
5 rows in set (0.00 sec)

you see that you have both and localhost for root user so both of them should work.

yes for some reason in PHP it only works with IP address… I tried many times… (in JSP it works with both the IP add and ‘localhost’…)

go figure…