Can't start phpMyAdmin. Keep getting the #2002 socket error

前端 未结 9 1848
难免孤独
难免孤独 2020-12-31 05:44

I\'ve been trying to set mysql and phpMyAdmin for the last 12 hours, without any success. And yes, after hours and hours of Google-ing I know that is a common problem and I\

相关标签:
9条回答
  • 2020-12-31 05:45
    1. Quit MAMP
    2. Open the terminal
    3. Type: killall -9 mysqld Restart MAMP
    0 讨论(0)
  • 2020-12-31 05:50

    check that mysql-server already installed if not sudo apt-get install mysql-server

    0 讨论(0)
  • 2020-12-31 05:52

    Since you did not mention MAMP, I am assuming you are not using it so this is for a manual install but it will likely also work for MAMP.

    In my experience, this is caused by the socket variable of your mysql. By default, MySQL uses /tmp/mysql.sock.

    You can get the MySQL socket variable by logging into your MySQL and doing

    show variables like '%socket%'
    

    that will show you the location of the socket file.

    Now, create a php phpinfo() file and look for mysql.default_socket under the mysql or mysqli section. Mine was /var/mysql/mysql.sock. This shows that PHP is looking for the file in a different location than mysql is using.

    Assuming you have same values, open new terminal and enter

    cd /var
    mkdir mysql
    cd mysql
    ln -s /tmp/mysql.sock mysql.sock
    

    this will create a link to the mysql socket file inside the location PHP is checking from.

    PHPMyAdmin should work now.

    0 讨论(0)
  • 2020-12-31 05:54

    Am using MAMP on a macbook pro running High Sierra, and in my case, I tried all the above but it still did not work for me so I did the following :

    1. Looking for where you installed your MAMP and more specifically, look for the "config.inc.php" file located in "/Applications/MAMP/bin/phpMyAdmin".

    1. Backup (ie. on a mac, right click and duplicate) the "config.inc.php" file before we touch it. You can call or rename it "config_old.inc.php"

    2. Open the file in your favorite IDE or text editor.

    1. Look for the following lines ;

    i) $cfg['Servers'][$i]['host']

    ii) $cfg['Servers'][$i]['port']

    iii) $cfg['Servers'][$i]['socket']

    Change from :

    $cfg['Servers'][$i]['host'] = 'localhost';
    

    to :

    $cfg['Servers'][$i]['host'] = '127.0.0.1';
    

    Change from :

    $cfg['Servers'][$i]['port'] = '3306';
    

    /this might be your default. Just check to see from your MAMP installation preference , press CMD + , and confirm that port number you have specified. In my case I had changed it to 8889./

    to :

    $cfg['Servers'][$i]['port'] = '8889';
    

    Again depending on where you installed your MAMP or to be more specific your mysql.

    Change from :

    $cfg['Servers'][$i]['socket'] = 'some_folder_path or EMPTY';
    

    to :

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

    After this modification, save and refresh in your web browser.

    Worked for me. Hope this helps. Cheers.

    0 讨论(0)
  • 2020-12-31 05:59

    The problem I had with this was because PHP was trying to connect via a UNIX socket instead of TCP. This is similar to this error: Error when connecting to MySQL using PHP/PDO

    First, make sure you have a my.cnf config for mysql then add your default socket location:

    [mysqld_safe] socket = /tmp/mysql.sock
    

    Next in your php.ini, let PHP know where it is:

    mysql.default_socket = /tmp/mysql.sock
    
    0 讨论(0)
  • 2020-12-31 06:05

    Check the config file:

    /* $cfg['Servers'][$i]['host'] = 'localhost'; */
    $cfg['Servers'][$i]['host'] = '127.0.0.1';
    $cfg['Servers'][$i]['compress'] = false;
    

    Restart MySQL: OSx : sudo /usr/local/mysql/support-files/mysql.server restart

    Linux: sudo service mysql start (Old linux: sudo /etc/init.d/mysql start)

    0 讨论(0)
提交回复
热议问题