Article:
  Apache Web-Serving With Mac OS X, Part 5
Subject:   test.php does not work
Date:   2002-07-13 04:45:17
From:   thegws
When I do the 'Post-installation wrap up' and enter the following into Terminal:


cd /usr/local/mysql/
sudo ./scripts/mysql_install_db
sudo chown -R mysql /usr/local/mysql
sudo ./bin/safe_mysqld --user=mysql &


it returns two lines that say:


Starting mysqld daemon with databases from /usr/local/mysql/data
020713 04:34:16 mysqld ended


Then when I do the next step of creating test.php and try to load it in my browser, it returns the following:


Warning: Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (61) in /Library/WebServer/Documents/test.php on line 5


Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (61)
in /Library/WebServer/Documents/test.php on line 5


Warning: Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (61) in /Library/WebServer/Documents/test.php on line 9


Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (61)
in /Library/WebServer/Documents/test.php on line 9


Warning: MySQL: A link to the server could not be established in /Library/WebServer/Documents/test.php on line 9


Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (61)


Can anyone help?

Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • test.php does not work
    2004-01-04 13:32:46  anonymous2 [View]

    I just had the same problem when installing phpmyadmin.

    I'm using OSX-Panther 10.3.2,
    fink installed mysql & entropy.ch php package.

    I'm not sure where this happens (guessing the fink build of mysql) ..

    but, in any case, php is using the default path to the mysql
    socket to connect, which is for us /Private/tmp/mysql.sock

    I believe, but my memory is fuzzy, that in 10.2 there was
    a /Private.

    now it is /private.

    If you look in your php.ini file and change (or add?)

    the line mysql.default_socket = /private/tmp/mysql.sock
    (or wherever mysql is writing a socket on your host machine)
    and restart apache / php , it should work.



  • test.php does not work
    2003-08-28 18:13:55  anonymous2 [View]

    ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
    [1] + Done sudo ./bin/safe_mysqld --user=mysql

    I tried to connect but failed. Can anyone tell me how to fix this? It's a real pain!!!
  • test.php does not work
    2002-07-23 23:17:01  macaddict [View]

    There are two things that can help. First, make sure that the chown command looks like:

    sudo chown -R mysql /usr/local/mysql/*

    or if you are already in that directory, you can also try

    sudo chown -R mysql .

    Make sure you list the directory (ls -al /usr/local/mysql) to ensure the chown command actually worked.

    For those who had trouble starting up the mysql daemon, first type "su", then enter your root password at the prompt. This will log you into the shell as root, and from that point on you don't need to type "sudo" to run a command that needs to run as root. Just make sure you exit the root session when you are done by typing "exit", otherwise every command afterwards will run with root priviledges, a good way to shoot yourself in the foot. At that point you can type "/usr/local/bin/mysql_safe --user=mysql &" and it should work as advertised.
  • test.php does not work
    2002-07-19 12:38:10  placebo [View]

    try this first and see if it works:

    turn your "web sharing" under the 'sharing' system preferences. it isn't as obvious as it should be but your computer is trying to reach itself and cannot connect because sharing is off.
    • test.php does not work
      2002-07-19 20:22:40  placebo [View]

      ...then try this:

      make sure the <password> is left blank in this line in the test.php file...

      // log into our local server using the MySQL root user.
      $dbh = mysql_connect( "localhost", "root", "<password>" );

      ...would read:

      // log into our local server using the MySQL root user.
      $dbh = mysql_connect( "localhost", "root", "" );

      i am having the same problem---as some people here are having here---in setting a mysql root password.