Ha! just got it to work - had to find the php.ini file first (in /
private/etc). Wasn't there, so:
1) sudo cp php.init.default php.ini
<supply password>
2) sudo chown <your username>:admin php.ini
3) chmod 755 php.ini
4) pico php.ini
<Ctrl-W>mysql.default_socket<Return key>
5) (mine was blank, yours may differ...) change the line to say:
mysql.default_socket = /tmp/mysql.sock <- the location where I found
the 'real' mysql.sock file
6) <Ctrl-O><Return key>
7) <Ctrl-X>
8) chmod 444 php.ini
9) sudo chown root:wheel php.ini
You may also, as a matter of course, check the httpd.conf file to
make sure apache is set up to use php (use <Ctrl-W> in pico to find
the line that has 'php.so' in it. Remove the hash "#" character at
the beginning of the line (if present). There's another place where
you have to be sure it's 'turned on'; these things come in pairs.
10) sudo apachectl restart
and then quit Safari (or other web browser) if running.
11) Using TextEdit, or XCode, create the following 'test' file named
phptest.php
<html>
<head>
<title>MySQL Test</title>
</head>
<body>
<p>Connecting to the database</p>
<?php
$host = 'localhost';
$user = 'root';
$pw = '<your MySQL root password>';
$link = mysql_connect($host, $user, $pw) or die('Could not
connect: '.mysql_error());
echo 'Connected successfully.';
?>
</body>
</html>
12) create a file, .tcshrc (or .bashrc if you prefer bash as your
default Terminal.app shell), and put an alias to /usr/local/mysql/bin/
mysql in there so when you start up Terminal.app, the shell will
start out with a handy alias to the mysql monitor program! This needs
to go at the root of your home folder.
13 from the shell, type 'mysql -u root -p'. If it asks for a
password, hit <Return> as the default install should not have any
password in it. Set the database to 'mysql' with
mysql>use mysql
database changed
mysql>set password for 'root'@'localhost' = PASSWORD('<choose a handy
root password - for MySQL only>')**
Query OK, 0 rows affected (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>exit
** - This is NOT the same password for the Unix root user under
Darwin (OS X)!!!
14) Exit your command shell, then exit Terminal.app also. Restart the
machine to restart apache, PHP, and the MySQL daemon.
15) Open Safari, and type "127.0.0.1/~<your username>/phptest.php
If all is okay, you should get a message, "Connected successfully.".
If you get an error about "...mysql.sock", then something above
didn't take. Make sure the 'mysql.sock' file really is in /tmp/
mysql.sock, and make sure the php.ini file editing 'took' (if you
forgot to do the 'chmod 755...' step above, this'll happen... Trust
me, I did it... unwittingly :) ) Also, try renaming ('mv') the
php.ini.default file - it might be interfering somehow. You'll need
to sudo it as it has root ownership.
This for
PHP - 4.4.1
MySQL - 5.0.24
OS X (Tiger) - 10.4.7
seems to work now.. :D
On Aug 11, 2006, at 9:47 PM, Phil M wrote:
On Aug 11, 2006, at 11:54 AM, William Squires wrote:
I'm trying to use PHP to connect to a MySQL database (to which I
have already set up). Individually each works (PHP - ver 4.4.1 and
MySQL ver 5.0.24 standard); I can write PHP into an html page, and
I can connect to my MySQL database through the 'mysql' command
from Terminal.app, but I can't get a connection from PHP to the
MySQL database
I don't believe that PHP is capable of accessing MySQL 5.0
databases... has to do with the new password scheme, and the fact
that the MySQL license became too restrictive to continue using
MySQL in future PHP development. In fact, MySQL is not the default
database for PHP 5.0... SQLite is.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>