on-upgrade 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Bug #1658067 reported by Cédric Avril
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
mysql-5.7 (Ubuntu)
Incomplete
Undecided
Unassigned

Bug Description

error message is a standard one when auto updating occurs after launching ubuntu.

ProblemType: Package
DistroRelease: Ubuntu 16.04
Package: mysql-server-5.7 5.7.17-0ubuntu0.16.04.1
ProcVersionSignature: Ubuntu 4.4.0-59.80-generic 4.4.35
Uname: Linux 4.4.0-59-generic i686
ApportVersion: 2.20.1-0ubuntu2.4
Architecture: i386
Date: Fri Jan 20 12:50:59 2017
ErrorMessage: subprocess installed post-installation script returned error exit status 1
InstallationDate: Installed on 2016-01-29 (357 days ago)
InstallationMedia: Ubuntu 15.10 "Wily Werewolf" - Release i386 (20151021)
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: ['symfony', 'performance_schema', 'odile', 'ibdata1', 'debian-5.7.flag', 'mysql_upgrade_info', 'ib_logfile0', 'phpmyadmin', 'mysql', 'sys', 'ib_logfile1', 'auto.cnf', 'ib_buffer_pool']
ProcCmdline: BOOT_IMAGE=/boot/vmlinuz-4.4.0-59-generic root=UUID=5b0a6a75-bb77-464a-a35a-930cccb6eccb ro quiet splash vt.handoff=7
RelatedPackageVersions:
 dpkg 1.18.4ubuntu1.1
 apt 1.2.18
SourcePackage: mysql-5.7
Title: package mysql-server-5.7 5.7.17-0ubuntu0.16.04.1 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1
UpgradeStatus: Upgraded to xenial on 2016-06-30 (204 days ago)
upstart.mysql.override: manual

Revision history for this message
Cédric Avril (naytheet) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in mysql-5.7 (Ubuntu):
status: New → Confirmed
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi,
from the log
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

That means the server did not start, and due to that later processes of the upgrade would fail - therefore it breaks here.

The error log itself doesn't hold too much on that - it seems to start shutting down right after being up:
2017-01-20T11:50:55.797820Z 0 [Note] mysqld: ready for connections.
Version: '5.7.17-0ubuntu0.16.04.1' socket: '/tmp/tmp.4JyEzHaYGM/mysqld.sock' port: 3306 (Ubuntu)
2017-01-20T11:50:55.798261Z 0 [Note] Giving 0 client threads a chance to die gracefully
2017-01-20T11:50:55.798287Z 0 [Note] Shutting down slave threads

Your config at https://launchpadlibrarian.net/303220958/MySQLConf.etc.mysql.mysql.conf.d.mysqld.cnf.txt uses the default socket path, so other than the unexpected immediate shutdown I don't see an issue.
I'd expect more a "error: Reason" anywhere, but this way I'm kind of lost.

The reason the messge shows up over and over again is that it retries every time.

I wonder if anything comes to your mind that this could be any sort of a special case to your custom setup of mysql?

Changed in mysql-5.7 (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Interesting - I found more similar reports which rises the chance that something is odd not that much tied to your personal setup.

I dupped it onto this bug.

summary: - package mysql-server-5.7 5.7.17-0ubuntu0.16.04.1 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'
summary: - mysql_upgrade: Got error: 2002: Can't connect to local MySQL server
- through socket '/var/run/mysqld/mysqld.sock'
+ on-upgrade 2002: Can't connect to local MySQL server through socket
+ '/var/run/mysqld/mysqld.sock'
Revision history for this message
Cédric Avril (naytheet) wrote : Re: [Bug 1658067] Re: package mysql-server-5.7 5.7.17-0ubuntu0.16.04.1 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1

Thanks for the help,

Actually I have to do /etc/init.d/mysql restart each time I'm using
mysql for the websites i'm developing locally (127.0.0.1) so it can
work. When I'm using symfony, I have to use these 2 lines to clear the
cache :

     php /var/www/Symfony/bin/console cache:clear
     chmod 777 -R /var/www/Symfony/var/cache/dev

which isn't quite nice. So maybe there's a problem with some files that
cannot be accessed. Just trying to help too. A password is needed for
pma, because I also had to use that :

     use mysql;
     CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass';
     GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost' IDENTIFIED BY
'pass';

in order to recover the password I had lost. I haven't used symfony for
a long time but I think I have to log in with user1 to make it work.

Le 23/01/2017 à 13:19, ChristianEhrhardt a écrit :
> Hi,
> from the log
> 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
>
> That means the server did not start, and due to that later processes of
> the upgrade would fail - therefore it breaks here.
>
> The error log itself doesn't hold too much on that - it seems to start shutting down right after being up:
> 2017-01-20T11:50:55.797820Z 0 [Note] mysqld: ready for connections.
> Version: '5.7.17-0ubuntu0.16.04.1' socket: '/tmp/tmp.4JyEzHaYGM/mysqld.sock' port: 3306 (Ubuntu)
> 2017-01-20T11:50:55.798261Z 0 [Note] Giving 0 client threads a chance to die gracefully
> 2017-01-20T11:50:55.798287Z 0 [Note] Shutting down slave threads
>
> Your config at https://launchpadlibrarian.net/303220958/MySQLConf.etc.mysql.mysql.conf.d.mysqld.cnf.txt uses the default socket path, so other than the unexpected immediate shutdown I don't see an issue.
> I'd expect more a "error: Reason" anywhere, but this way I'm kind of lost.
>
> The reason the messge shows up over and over again is that it retries
> every time.
>
> I wonder if anything comes to your mind that this could be any sort of a
> special case to your custom setup of mysql?
>
>
> ** Changed in: mysql-5.7 (Ubuntu)
> Status: Confirmed => Incomplete
>

Revision history for this message
Jordao (carlosjordao) wrote :

In my case, the mysql-server is installed, but the systemd service were marked as disable.
Once I have enabled it and typed 'apt-get -f install', mysql has been upgraded.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

@Lars & Robie - there was a flurry of mysql upgrade issues in the recent days.
I was able to identify two different behaviours and dupp'ed all others.
Subscribing you two for a deeper though on it while waiting for the reporters to share more on their setup.

Revision history for this message
Robie Basak (racb) wrote :

> In my case, the mysql-server is installed, but the systemd service were marked as disable.

Ah. In this case, this is a known issue. I'll mark it as a duplicate. Thanks!

Revision history for this message
Cédric Avril (naytheet) wrote : Re: [Bug 1658067] Re: mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Rights for /var/run/mysqld/mysqld.sock are 777 and owner is mysql. I
don't remember if mysql exists as an user. There is also a
mysqld.sock.lock. Both files are empty. What is the file used to
configure mysql?

Le 23/01/2017 à 14:08, ChristianEhrhardt a écrit :
> ** Summary changed:
>
> - package mysql-server-5.7 5.7.17-0ubuntu0.16.04.1 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'
>
> ** Summary changed:
>
> - mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
> + on-upgrade 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
>

Revision history for this message
Chris Larson (cklarson) wrote :

@Jordao This solution solved my problem. After an hour or so of trying things. Thank you.

Revision history for this message
salsaman (salsaman) wrote :

I had a similar problem to this. All updates and installs via apt-get were blocked because mysql failed to upgrade, with similar error messages as above.

In my case the problem turned out to be due to the fact that I had removed /etc/rc5.d/S03mysql in order to prevent mysql from starting at runtime. Recreating the symlink was the only way I found to allow the update to succeed.

IMO the script ought to check if this symlink exists and if not create it temporarily, or better still use a method which does not depend on rc.d.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.