Search code examples
phpmysqlsocketsphpmyadminmacports

MacPorts Upgraded MAMP with PHPMyAdmin Error #2002


I upgraded MacPorts PHP to 5.5 sudo port install php55 and sudo port select php php55:

 php --version
PHP 5.5.15 (cli) (built: Jul 25 2014 13:17:32) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

I added some other necessary ports using

sudo port install php55-xdebug php55-sqlite php55-pear php55-openssl php55-mysql php55-memcached php55-mcrypt php55-mbstring php55-imagick php55-iconv php55-gd php55-curl

I upgraded MySQL to 5.5

sudo port install mysql55 +server
sudo /opt/local/lib/mysql55/bin/mysql_install_db --user=mysql
sudo /opt/local/share/mysql55/support-files/mysql.server start
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql55-server.plist

and got the new version up and running:

mysql --version
mysql  Ver 14.14 Distrib 5.5.38, for osx10.9 (x86_64) using readline 5.1

and

ps -e | grep mysql
   64 ??         0:00.01 /opt/local/bin/daemondo --label=mysql55-server --start-cmd /opt/local/lib/mysql55/bin/mysqld --user=_mysql ; --pid=exec
   72 ??         0:01.33 /opt/local/lib/mysql55/bin/mysqld --user=_mysql

as it was necessary to run phpmyadmin sudo port install mysql55. Just as I needed some other php ports

sudo port install php55-openssl
sudo port install php55-mbstring
sudo port install php55-mysqli

I also did a port upgrade outdated to update all ports and got a new PHPMyAdmin

sudo mysqladmin -u root -p password works now thanks to an explanation by Bill Christensen on MacPorts users mailing list and I set a new password. After that I could enter mysql client using the newly picked password:

mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.38 Source distribution

I think initially I forgot to set it properly AND I used mysql5 instead of mysql to access the MySQLMonitor. Socket is correct now in the phpmyadmin config.inc.php at /opt/local/www/phpmyadmin : $cfg['Servers'][$i]['socket'] = '/opt/local/var/run/mysql55/mysqld.sock'; and inside the php.ini at /opt/local/etc/php55/php.ini: mysql.default_socket = /opt/local/var/run/mysql55/mysqld.sock. PHP.INI running I found using php -i | grep 'Configuration File' btw.

I found the socket using:

netstat |grep mysql
5bec9f8c29ee0bd1 stream      0      0 5bec9f8c2c22e159                0                0                0 /opt/local/var/run/mysql55/mysqld.sock

The error #2002 Cannot log in to the MySQL server accessing PHPMyAdmin is still there though I cannot log in to the MySQL server so no change getting into phpmyadmin.

I read PHPMyAdmin of MAMP giving me #2002 mysql error and tried

ps -e|grep mysqld
sudo mysqld_safe

in vain.

What am I missing here?


Solution

  • When I changed to $cfg['Servers'][$i]['connect_type'] = 'socket'; instead of tcp in config.inc.pho in PHPMyAdmin I can access the phpmyadmin control panel. TCP is not working with the current settings. Will look into making that possible too (Ryan at Macports showed me that connecting via network is turned off by default), but works like this now. To move databases from the old location to the new one I used sudo cp -R /opt/local/var/db/mysql5/datasbase /opt/local/var/db/mysql55/database and did a sudo chown _mysql:_mysql database