mysql: mysql postinst fails after running apt-get upgrade
Cookbook version
7.1.1
Chef-client version
12.10.24
Platform Details
Ubuntu 16.04.1 LTS
Scenario:
Attempt to upgrade the mysql-server-5.7 package
Steps to Reproduce:
My recipe is as follows:
mysql_service 'default' do
initial_root_password 'changeme'
action [:create, :start]
end
mysql_client 'default' do
action :create
end
This all worked as expected.
A few weeks later I ran apt-get upgrade which didn’t complete as the mysql-server-5.7.postinst script fails.
Expected Result:
The mysql-server-5.7 package is successfully upgraded.
Actual Result:
mysql-server-5.7.postinst fails during the upgrade process with the following output:
+ mysql_upgrade --defaults-file=/etc/mysql/debian.cnf
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.
+ result=11
+ '[' 11 -ne 0 -a 11 -ne 2 ']'
+ echo 'mysql_upgrade failed with exit status 11'
mysql_upgrade failed with exit status 11
+ exit 1
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)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (4 by maintainers)
OK, had to get dirty to make this work. Apparmor definitely wasn’t helping matters either.
apt install apparmor-utils aa-complain /usr/sbin/mysqld cd /tmp/ apt-get download mysql-server-5.7 dpkg --unpack mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb rm /var/lib/dpkg/info/mysql-server-5.7.postinst dpkg --configure mysql-server-5.7 service mysql-default restart
Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu)Given the cookbook avoids the packaged installation mechanisms as much as possible I don’t think there is too much harm in not having the postinst script run on a minor increment.
What helped for me was running ‘systemctl enable mysql’ and running ‘apt-get install -f’ again.
When I try
systemctl enable mysqlthen, I try
systemctl disable mysql, and thensystemctl enable mysqlworked!finally, run ‘apt-get install -f’ again.
@Tealc002 I can confirm that works for me. I can finally, successfully run apt-get update.