Articles in this section

MySQL/MariaDB service cannot be started during Plesk update: ERROR 2002 (HY000): Can't connect to local MySQL server through socket

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

  • MySQL/MariaDB server is not started during Plesk update. The following errors can be found in /var/log/plesk/install/autoinstaller3.log :

    CONFIG_TEXT: Failed to start mysql.service: Unit not found.
    Trying to start service mysql... inactive
    WARNING!
    Some problems are found during start service mysql(see log file: /var/log/plesk/install/plesk_18.0.28_installation.log)
    Continue...
    Trying to start service mysql... inactive
    Trying to establish test connection...ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

  • Checking mysql service status with systemctl utility results in:

    # systemctl status mariadb.service
    Unit mariadb.service could not be found.
    # systemctl status mysql.service
    Unit mariadb.service could not be found.
    # systemctl status mysqld.service
    Unit mariadb.service could not be found.

  • mysql service can be started manually with the command:

    # service mysql start

  • SystemD-based OS is used

Cause

MySQL or MariaDB service misconfiguration.

Symbolic link for mysql service in /etc/systemd/system/ directory points to non-existing file:

# ls -la /etc/systemd/system/mariadb.service
lrwxrwxrwx 1 root root 38 Jul 29 2016 mariadb.service -> /usr/lib/systemd/system/mysqld.service
# ls -la /usr/lib/systemd/system/mysqld.service
ls: cannot access /usr/lib/systemd/system/mysqld.service: No such file or directory

Resolution

  1. Log in to Plesk server using SSH.

  2. Make sure that service definition is installed in /usr/lib/systemd/system/mariadb.service.

    # ls -la /usr/lib/systemd/system/mariadb.service
    -rw-r--r-- 1 root root 1697 Aug 16 2018 /usr/lib/systemd/system/mariadb.service

  3. Make sure that there is no startup script for mysql service in /etc/init.d/ directory and remove if it exists:

    # rm -f /etc/init.d/mysql

  4. Remove broken symbolic link:

    # rm -f /etc/systemd/system/mariadb.service

  5. Reload systemd daemon:

    # systemctl daemon-reload

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.