0

I've looked through related posts and their suggested solutions (here and here) but they don't seem to help in my situation.

I'm running MacPorts 2.1.2 on Snow Leopard, and I've got the following packages installed:

php5-mysql @5.3.15_0+mysql5 (active)
php5 @5.3.15_0+apache2 (active)
mysql5 @5.1.63_0 (active)
mysql_select @0.1.2_0 (active)
apache2 @2.2.22_2+preforkmpm (active)

I can point my web browser at localhost and it will connect to the default site; a test index.php

<?php phpinfo() ?>

page works fine as well, so I assume at this point that PHP is functional. The problem is connecting to the installed MySQL server. Neither phpmyadmin nor Joomla can seem to connect, and trying a .php test script resulted in problems too. I'm a bit at loss as to how to proceed from here.

The MySQL server is apparently running:

~ > ps ax | grep mysql
10884   ??  S      0:00.03 /bin/sh /opt/local/lib/mysql5/bin/mysqld_safe
10930   ??  S      0:07.66 /opt/local/libexec/mysqld --basedir=/opt/local --datadir=/opt/local/var/db/mysql5 --user=_mysql --log-error=/opt/local/var/db/mysql5/tigger.local.err --pid-file=/opt/local/var/db/mysql5/tigger.local.pid

and I am able to use the mysql client:

~ > mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.1.63 Source distribution

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.04 sec)

mysql> show grants for 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

There's the socket

~ > ll /opt/local/var/run/mysql5/mysqld.sock 
srwxrwxrwx 1 _mysql admin 0 Jul 31 16:55 /opt/local/var/run/mysql5/mysqld.sock

and the php.ini contains the MySQL module and configuration

~ > /opt/local/bin/php -i | grep mysql | grep socket
mysql.default_socket => /opt/local/var/run/mysql5/mysqld.sock => /opt/local/var/run/mysql5/mysqld.sock
mysqli.default_socket => no value => no value
pdo_mysql.default_socket => /opt/local/var/run/mysql5/mysqld.sock => /opt/local/var/run/mysql5/mysqld.sock

It all seems to me as this is how things should be. However, when I try to log into phpmyadmin using 'root' the connection fails, and the same happens during Joomla setup.

Any help, hints, suggestions are appreciated :-)

Community
  • 1
  • 1
Jens
  • 8,423
  • 9
  • 58
  • 78
  • Is there some error message with your failed connection? Also the term localhost has some special meaning with mysql. Maybe that's some cause of a problem. – hakre Aug 01 '12 at 18:08
  • From phpmyadmin I get: #1045 Cannot log in to the MySQL server. And from Joomla I get: Could not connect to the database. Connector returned number: Unable to connect to the Database: Could not connect to MySQL. – Jens Aug 01 '12 at 18:15
  • So you want to connect via socket or via ip? – hakre Aug 01 '12 at 18:18
  • Uh.. I don't know :) I want Joomla running. I guess either way (socket or IP) works for me, not sure what the advantage of either one would be. – Jens Aug 01 '12 at 21:06

1 Answers1

0

First off, I found this thread which was helpful and let me verify that what I did was ok.

What was missing on my end:

  1. I added the /opt/local/var/run/mysql5/mysqld.sock to the etc/php5/php.ini file explicitly. Not sure if this changed anything, but now all of php has access to the socket:

    /opt/local/etc > /opt/local/bin/php -i | grep mysql | grep socket
    mysql.default_socket => /opt/local/var/run/mysql5/mysqld.sock => /opt/local/var/run/mysql5/mysqld.sock
    mysqli.default_socket => /opt/local/var/run/mysql5/mysqld.sock => /opt/local/var/run/mysql5/mysqld.sock
    pdo_mysql.default_socket => /opt/local/var/run/mysql5/mysqld.sock => /opt/local/var/run/mysql5/mysqld.sock
    
  2. I could have sworn I did this, but I tried it anyway: /opt/local/lib/mysql5/bin/mysqladmin -u root password '..' and now both Joomla and phpmyadmin connect to the mysqld.

That's all! The Test Script of the other thread works just fine as well.

Community
  • 1
  • 1
Jens
  • 8,423
  • 9
  • 58
  • 78