mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server

Bug #1605948 reported by Firmansyah on 2016-07-24
94
This bug affects 21 people
Affects Status Importance Assigned to Milestone
mysql-5.7 (Ubuntu)
High
Unassigned

Bug Description

After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up mysql-server-5.7 (5.7.13-0ubuntu0.16.04.2) ...
Renaming removed key_buffer and myisam-recover options (if present)
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

ProblemType: Package
DistroRelease: Ubuntu 16.04
Package: mysql-server-5.7 5.7.13-0ubuntu0.16.04.2
ProcVersionSignature: Ubuntu 4.4.0-24.43-generic 4.4.10
Uname: Linux 4.4.0-24-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
Date: Sun Jul 24 08:14:47 2016
ErrorMessage: subprocess installed post-installation script returned error exit status 1
InstallationDate: Installed on 2016-04-26 (88 days ago)
InstallationMedia: Ubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
Logs.var.log.daemon.log:

MySQLConf.etc.mysql.conf.d.mysql.cnf: [mysql]
MySQLConf.etc.mysql.conf.d.mysqldump.cnf:
 [mysqldump]
 quick
 quote-names
 max_allowed_packet = 16M
MySQLConf.etc.mysql.mysql.conf.d.mysqld_safe_syslog.cnf:
 [mysqld_safe]
 syslog
MySQLVarLibDirListing: ['auto.cnf', 'brm', 'ib_logfile0', 'ibdata1', 'sys', 'ib_buffer_pool', 'performance_schema', 'ib_logfile1', 'mysql', 'debian-5.7.flag']
ProcCmdline: BOOT_IMAGE=/boot/vmlinuz-4.4.0-24-generic.efi.signed root=UUID=1f7e918c-d6e9-41d4-b7fb-89decfb7104b ro quiet splash vt.handoff=7
RelatedPackageVersions:
 dpkg 1.18.4ubuntu1.1
 apt 1.2.12~ubuntu16.04.1
SourcePackage: mysql-5.7
Title: package mysql-server-5.7 5.7.13-0ubuntu0.16.04.2 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1
UpgradeStatus: No upgrade log present (probably fresh install)

Firmansyah (firmanium) wrote :
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mysql-5.7 (Ubuntu):
status: New → Confirmed

The Ubuntu QA process is really going downhill. First they break NTP, now they break MySQL. And this is in 16.04LTS, not even bleeding-edge !!

Setting up mysql-server-5.7 (5.7.13-0ubuntu0.16.04.2) ...
Renaming removed key_buffer and myisam-recover options (if present)
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for " for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Mon 2016-07-25 15:03:20 BST; 9min ago
 Main PID: 29823 (code=exited, status=0/SUCCESS)

Jul 25 15:03:19 XXXX systemd[1]: mysql.service: Unit entered failed state.
Jul 25 15:03:19 XXXX systemd[1]: mysql.service: Failed with result 'exit-code'.
Jul 25 15:03:20 XXXX systemd[1]: mysql.service: Service hold-off time over, scheduling restar
Jul 25 15:03:20 XXXX systemd[1]: Stopped MySQL Community Server.
Jul 25 15:03:20 XXXX systemd[1]: mysql.service: Start request repeated too quickly.
Jul 25 15:03:20 XXXX systemd[1]: Failed to start MySQL Community Server.

My mySQL was working perfectly well until today's upgrade.

Changed in mysql-5.7 (Ubuntu):
importance: Undecided → High
Robie Basak (racb) on 2016-08-02
summary: - package mysql-server-5.7 5.7.13-0ubuntu0.16.04.2 failed to
- install/upgrade: subprocess installed post-installation script returned
- error exit status 1
+ mysql_upgrade: Got error: 2002: Can't connect to local MySQL server
+ through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the
+ MySQL server
lpuzio (leszekpuzio) wrote :

Hi,

I had the same error. I solved this by one command:
sudo systemctl enable mysql

Than I had to start MySql:
sudo service mysql start

After this I was able to update:
sudo apt dist-upgrade

One could try to recreate this bug by disabling MySql before upgrade:
sudo systemctl disable mysql

I hope this helped you.

Regards,

Lyle (mamadontgodaddycomehome) wrote :

The workaround suggested by @lpuzio worked for me with the same problem. Thanks.

pickett.aaron (pickett-aaron) wrote :

I am having a issue with a new install of 16.04.01:

trsbox:~$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

trsbox:~$ mysqladmin -u root -p status
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

trsbox:~$ sudo systemctl enable mysql
[sudo] password for scorch:
Synchronizing state of mysql.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable mysql

trsbox:~$ sudo service mysql start
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

trsbox:~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Fri 2017-02-17 12:54:34 EST; 17s ago
  Process: 4248 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
  Process: 4244 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 4248 (code=exited, status=2); : 4249 (mysql-systemd-s)
    Tasks: 2
   Memory: 12.3M
      CPU: 730ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─4249 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─4314 sleep 1

pickett.aaron (pickett-aaron) wrote :
Download full text (4.9 KiB)

And:

trsbox:~$ sudo journalctl -xe
Feb 17 13:01:41 trsbox.net audit[5682]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=5682 comm="mysqld" requested_mask="r"
Feb 17 13:01:41 trsbox.net audit[5682]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5682/status" pid=5682 comm="mysqld" requested_mask="r" denied_
Feb 17 13:01:41 trsbox.net kernel: audit: type=1400 audit(1487354501.565:143): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5682/status" pid=5682 comm=
Feb 17 13:01:41 trsbox.net kernel: audit: type=1400 audit(1487354501.565:144): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=56
Feb 17 13:01:41 trsbox.net kernel: audit: type=1400 audit(1487354501.565:145): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5682/status" pid=5682 comm=
Feb 17 13:01:41 trsbox.net systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 17 13:01:42 trsbox.net sshd[5648]: Failed password for root from 183.214.141.101 port 19744 ssh2
Feb 17 13:01:43 trsbox.net sshd[5652]: Failed password for root from 123.183.209.136 port 19999 ssh2
Feb 17 13:01:44 trsbox.net sshd[5652]: Received disconnect from 123.183.209.136 port 19999:11: [preauth]
Feb 17 13:01:44 trsbox.net sshd[5652]: Disconnected from 123.183.209.136 port 19999 [preauth]
Feb 17 13:01:44 trsbox.net sshd[5652]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=123.183.209.136 user=root
Feb 17 13:01:46 trsbox.net sshd[5648]: Failed password for root from 183.214.141.101 port 19744 ssh2
Feb 17 13:01:48 trsbox.net sshd[5648]: Failed password for root from 183.214.141.101 port 19744 ssh2
Feb 17 13:01:48 trsbox.net sshd[5648]: error: maximum authentication attempts exceeded for root from 183.214.141.101 port 19744 ssh2 [preauth]
Feb 17 13:01:48 trsbox.net sshd[5648]: Disconnecting: Too many authentication failures [preauth]
Feb 17 13:01:48 trsbox.net sshd[5648]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=183.214.141.101 user=root
Feb 17 13:01:48 trsbox.net sshd[5648]: PAM service(sshd) ignoring max retries; 6 > 3
Feb 17 13:01:50 trsbox.net sshd[5729]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Feb 17 13:01:50 trsbox.net sshd[5729]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Feb 17 13:01:51 trsbox.net sshd[5729]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=183.214.141.101 user=root
Feb 17 13:01:52 trsbox.net sshd[5737]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Feb 17 13:01:52 trsbox.net sshd[5737]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Feb 17 13:01:53 trsbox.net sshd[5739]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Feb 17 13:01:53 trsbox.net sshd[5739]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Feb 17 13:01:53 trsbox.net sshd[5729]: Failed password for root from 183.214.141.101 port 47025 ssh2
Feb 17 13:01:54 trsbox.net sshd[5737]: pam_unix(sshd:auth): authenticati...

Read more...

kro (stiolbe) wrote :

The workaround suggested by @lpuzio doesn't seem to work on bash for windows

Melvin Williams (8-private) wrote :

@lpuzio workaround worked for me too

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers