Unable connect to local MySQL server through socket '/tmp/mysql.sock' (2) while trying to install application

Created:

2016-11-16 12:51:10 UTC

Modified:

2017-08-16 15:43:10 UTC

13

Was this article helpful?


Have more questions?

Submit a request

Unable connect to local MySQL server through socket '/tmp/mysql.sock' (2) while trying to install application

Applicable to:

  • Plesk for Linux

Symptoms

  1. Installation of application in Domains > example.com > Website & Settings > Applications > Install application or an attempt to access WordPress Toolkit page fails with the error:
    Exception: ODBC error #08S01: [unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    file: /usr/share/aps_php/aps_php.php
    line: 12519
    code: 0
  2. Attempt to get APS global settings manually results in an error:

    [root@server ~]# /usr/local/psa/bin/aps --get-packages-global-settings
    [2017-05-26 16:12:17] ERR [panel] Unable to get apsc.aps_registry_package row from psa.smb_apsPackage with ID = 1. Details: exception 'Exception' with message 'ODBC error #08S01: [unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' in /usr/share/aps_php/aps_php.php:12519
    Stack trace:
    #0 /usr/share/aps_php/aps_php.php(12519): aps_controller_registry_getpackage(Resource id #173, '1d4269c7-dcbb-4...')
    #1 /usr/local/psa/admin/plib/Smb/Db/Table/Row/ApsPackage.php(67): APS_Controller_Registry->getPackage('1d4269c7-dcbb-4...')
    #2 /usr/local/psa/admin/plib/api-common/cuAps.php(1499): Smb_Db_Table_Row_ApsPackage->getRegistryPackage()
    #3 /usr/local/psa/admin/plib/api-common/cuAps.php(552): cuAps->_getPackagesGlobalSettings()
    #4 /usr/local/psa/admin/plib/api-common/AbstractCuExecutor.php(55): cuAps->__construct(NULL)
    #5 /usr/local/psa/admin/plib/api-common/CuExecutor.php(35): AbstractCuExecutor->_execUtil('cuAps', NULL)
    #6 /usr/local/psa/admin/plib/api-cli/CliUtilityRunner.php(27): CuExecutor->run()
    #7 /usr/local/psa/admin/plib/api-cli/CliUtilityRunner.php(65): CliUtilityRunner->run()
    #8 /usr/local/psa/admin/plib/api-cli/aps.php(4): require_once('/usr/local/psa/...')
    #9 {main}
    @packages = (
    );

Cause

The /tmp/mysql.sock link does not exist.

Resolution

  1. Check /tmp/mysql.sock link file:

    [root@server ~]# ls -ld /tmp/mysql.sock
    ls: cannot access /tmp/mysql.sock: No such file or directory
  2. Create the link if it does not exist:

    # ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Have more questions? Submit a request
Please sign in to leave a comment.