Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAMP - phpMyAdmin #2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock'

I was working on MAMP phpMyAdmin and everything worked well until i query an ALTER TABLE statement from SQL tab. Operation was too long to end so i decided to refresh my page. From this time, i cannot reach phpMyAdmin anymore and i always have this message :

#2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

I've tried a lot of things found on the net, including on Stackoverflow, Server Fault, ... like reinstalling MAMP, symlink to /tmp/mysql.sock, modify config.inc.php, etc, but nothing worked.

Everything's good when i run mysql from command line :

$ /Applications/MAMP/Library/bin/mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.29 Source distribution

mysql> SHOW SCHEMAS;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0,65 sec)

mysqld is properly running :

$ ps -e | grep mysql
 7007 ??         0:00.03 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
 7141 ??         0:00.37 /Applications/MAMP/Library/bin/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --plugin-dir=/Applications/MAMP/Library/lib/plugin --lower-case-table-names=0 --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=8889

And socket file exist :

$ ls -la /Applications/MAMP/tmp/mysql/mysql.sock 
srwxrwxrwx  1 user  admin  0 21 avr 16:57 /Applications/MAMP/tmp/mysql/mysql.sock

Someone had already faced this kind of issue ?

like image 466
Yaman Avatar asked Apr 21 '13 16:04

Yaman


People also ask

Does MAMP have phpMyAdmin?

In MAMP, you need to open phpMyAdmin to create a MySQL database. If you have installed MAMP with the default ports, open the Welcome page in your browser (http://localhost:8888/MAMP/), then click the phpMyAdmin link at the top of the screen. The main phpMyAdmin screen will appear.

Why phpMyAdmin is not working in MAMP?

You may receive an error message stating that phpMyAdmin needs a PHP version within a specific range. This might happen if you're running an outdated version of PHP, or a new update is not compatible with your version of MAMP. In this case, you”ll need to change the PHP version of your MAMP application.

How do I access phpMyAdmin on Mac?

You should be able to access phpMyAdmin directly, by browsing to http://127.0.0.1/phpmyadmin. Log in to phpMyAdmin by using the following credentials: Username: root. Password: The same as the application password.


Video Answer


2 Answers

I am seeing exactly the same. MAMP MySQL running, and this messgage from PHPMyAdmin

MySQL said:

#2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

The server is not responding (or the local server's socket is not correctly configured).

I did use : sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock to allow local PHP CLI access to MAMP MySQL

I found the config file for phpMyAdmin here: /Applications/MAMP/bin/phpMyAdmin/config.inc.php

I added this explicit path in the config file.

$cfg['Servers'][$i]['socket'] = '/Applications/MAMP/tmp/mysql/mysql.sock';

Now it works :)

like image 104
thinkadoo Avatar answered Oct 19 '22 04:10

thinkadoo


I got the same response when I went to the default URI via the link from the main Mamp page, which was http://localhost/phpMyAdmin/?lang=en-iso-8859-1&language=English. I tried the previous answer's suggestions to no avail. But then, when I chopped off some of the options in the URI and instead just went to any of the following:

  • http://localhost/phpMyAdmin/?language=English
  • http://localhost/phpMyAdmin/?lang=en-iso-8859-1
  • http://localhost/phpMyAdmin

then it worked.

like image 23
beth Avatar answered Oct 19 '22 04:10

beth