Manually removing /etc/mysql results in install/upgrade failures, with errors like "Can't read dir of '/etc/mysql/conf.d/'"

Bug #1914636 reported by Muhammad Naufal Hilmy Makarim
82
This bug affects 14 people
Affects Status Importance Assigned to Milestone
mysql-8.0 (Ubuntu)
Triaged
Wishlist
Lars Tangvald

Bug Description

$ sudo apt purge mysql-server
$ sudo rm -rf /etc/mysql
$ dpkg -l | grep mysql
result:
ii libmysqlclient21:amd64 8.0.23-0ubuntu0.20.04.1 amd64 MySQL database client library
ii mysql-common 5.8+1.0.5ubuntu2 all MySQL database common files, e.g. /etc/mysql/my.cnf

sudo apt-get install mysql-server
result:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7
  libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl libmecab2
  mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
  mysql-client-core-8.0 mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
  libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
  libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7
  libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl libmecab2
  mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
  mysql-client-core-8.0 mysql-server mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 16 newly installed, 0 to remove and 2 not upgraded.
Need to get 30,6 MB/30,6 MB of archives.
After this operation, 249 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-client-core-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [4.215 kB]
Get:2 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-client-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [22,0 kB]
Get:3 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libaio1 amd64 0.3.112-5 [7.184 B]
Get:4 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libevent-core-2.1-7 amd64 2.1.11-stable-1 [89,1 kB]
Get:5 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libevent-pthreads-2.1-7 amd64 2.1.11-stable-1 [7.372 B]
Get:6 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libmecab2 amd64 0.996-10build1 [233 kB]
Get:7 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-server-core-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [17,7 MB]
Get:8 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-server-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [1.275 kB]
Get:9 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-pm-perl all 4.46-1 [186 kB]
Get:10 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libfcgi-perl amd64 0.79-1 [33,1 kB]
Get:11 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-fast-perl all 1:2.15-1 [10,5 kB]
Get:12 http://id.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-template-perl all 2.97-1 [59,0 kB]
Get:13 http://id.archive.ubuntu.com/ubuntu focal/main amd64 mecab-utils amd64 0.996-10build1 [4.912 B]
Get:14 http://id.archive.ubuntu.com/ubuntu focal/main amd64 mecab-ipadic all 2.7.0-20070801+main-2.1 [6.714 kB]
Get:15 http://id.archive.ubuntu.com/ubuntu focal/main amd64 mecab-ipadic-utf8 all 2.7.0-20070801+main-2.1 [4.380 B]
Fetched 30,6 MB in 2min 11s (233 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-client-core-8.0.
(Reading database ... 171059 files and directories currently installed.)
Preparing to unpack .../00-mysql-client-core-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mysql-client-core-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../01-mysql-client-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../02-libaio1_0.3.112-5_amd64.deb ...
Unpacking libaio1:amd64 (0.3.112-5) ...
Selecting previously unselected package libevent-core-2.1-7:amd64.
Preparing to unpack .../03-libevent-core-2.1-7_2.1.11-stable-1_amd64.deb ...
Unpacking libevent-core-2.1-7:amd64 (2.1.11-stable-1) ...
Selecting previously unselected package libevent-pthreads-2.1-7:amd64.
Preparing to unpack .../04-libevent-pthreads-2.1-7_2.1.11-stable-1_amd64.deb ...
Unpacking libevent-pthreads-2.1-7:amd64 (2.1.11-stable-1) ...
Selecting previously unselected package libmecab2:amd64.
Preparing to unpack .../05-libmecab2_0.996-10build1_amd64.deb ...
Unpacking libmecab2:amd64 (0.996-10build1) ...
Selecting previously unselected package mysql-server-core-8.0.
Preparing to unpack .../06-mysql-server-core-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mysql-server-core-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Selecting previously unselected package mysql-server-8.0.
Preparing to unpack .../07-mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
grep: /etc/mysql/: No such file or directory
Unpacking mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../08-libcgi-pm-perl_4.46-1_all.deb ...
Unpacking libcgi-pm-perl (4.46-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../09-libfcgi-perl_0.79-1_amd64.deb ...
Unpacking libfcgi-perl (0.79-1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../10-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../11-libhtml-template-perl_2.97-1_all.deb ...
Unpacking libhtml-template-perl (2.97-1) ...
Selecting previously unselected package mecab-utils.
Preparing to unpack .../12-mecab-utils_0.996-10build1_amd64.deb ...
Unpacking mecab-utils (0.996-10build1) ...
Selecting previously unselected package mecab-ipadic.
Preparing to unpack .../13-mecab-ipadic_2.7.0-20070801+main-2.1_all.deb ...
Unpacking mecab-ipadic (2.7.0-20070801+main-2.1) ...
Selecting previously unselected package mecab-ipadic-utf8.
Preparing to unpack .../14-mecab-ipadic-utf8_2.7.0-20070801+main-2.1_all.deb ...
Unpacking mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../15-mysql-server_8.0.23-0ubuntu0.20.04.1_all.deb ...
Unpacking mysql-server (8.0.23-0ubuntu0.20.04.1) ...
Setting up libmecab2:amd64 (0.996-10build1) ...
Setting up mysql-client-core-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Setting up libcgi-pm-perl (4.46-1) ...
Setting up libhtml-template-perl (2.97-1) ...
Setting up mecab-utils (0.996-10build1) ...
Setting up libevent-core-2.1-7:amd64 (2.1.11-stable-1) ...
Setting up mysql-client-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Setting up libfcgi-perl (0.79-1) ...
Setting up libaio1:amd64 (0.3.112-5) ...
Setting up libevent-pthreads-2.1-7:amd64 (2.1.11-stable-1) ...
Setting up mecab-ipadic (2.7.0-20070801+main-2.1) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|

done!
update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mysql-server-core-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Setting up mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|

done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
update-alternatives: warning: alternative /etc/mysql/my.cnf.fallback (part of link group my.cnf) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/my.cnf is dangling; it will be updated with best choice
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
ERROR: Unable to start MySQL server:
mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Once the problem is resolved, run apt-get --fix-broken install to retry.
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (245.4-4ubuntu3.4) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                          Processing triggers for man-db (2.9.1-1...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

---------------------
Fixing method:
Check if /etc/mysql directory exist. If it exist, then check if /etc/mysql/conf.d/ exist. It it not exist, then check if /etc/mysql/mysql.conf.d exist. If it exist then run the command below.
$ sudo ln -s /etc/mysql/mysql.conf.d /etc/mysql/conf.d
That command create symbolic link to provide compatibility. After that, run command below.
$ sudo apt-get --fix-broken install

That's it ^_^

ProblemType: Package
DistroRelease: Ubuntu 20.04
Package: mysql-server-8.0 8.0.23-0ubuntu0.20.04.1
ProcVersionSignature: Ubuntu 5.8.0-41.46~20.04.1-generic 5.8.18
Uname: Linux 5.8.0-41-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.16
Architecture: amd64
CasperMD5CheckResult: skip
Date: Thu Feb 4 22:07:18 2021
ErrorMessage: installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
InstallationDate: Installed on 2021-02-02 (2 days ago)
InstallationMedia: Ubuntu 20.04.1 LTS "Focal Fossa" - Release amd64 (20200731)
Logs.var.log.daemon.log:

Logs.var.log.mysql.error.log:
ProcCmdline: BOOT_IMAGE=/boot/vmlinuz-5.8.0-41-generic root=UUID=14c642a5-0b37-49dd-a948-764dae2c06ca ro quiet splash vt.handoff=7
Python3Details: /usr/bin/python3.8, Python 3.8.5, python3-minimal, 3.8.2-0ubuntu2
PythonDetails: N/A
RelatedPackageVersions:
 dpkg 1.19.7ubuntu3
 apt 2.0.4
SourcePackage: mysql-8.0
Title: package mysql-server-8.0 8.0.23-0ubuntu0.20.04.1 failed to install/upgrade: installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Muhammad Naufal Hilmy Makarim (mnaufalhilmym) wrote :
Revision history for this message
Muhammad Naufal Hilmy Makarim (mnaufalhilmym) wrote :

---------------------
Fixing method:
Check if /etc/mysql directory exist. If it exist, then check if /etc/mysql/conf.d/ exist. It it not exist, then check if /etc/mysql/mysql.conf.d exist. If it exist then run the command below.
$ sudo ln -s /etc/mysql/mysql.conf.d /etc/mysql/conf.d
That command create symbolic link to provide compatibility. After that, run command below.
$ sudo apt-get --fix-broken install

That's it ^_^

tags: removed: need-duplicate-check
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Muhammad,
IMHO the problem is right at the start, one should not manually remove /ect/* files :-)
But ok, let us consider it happened somehow and you now need to resolve things.

If you look at this example you'll see that /etc/mysql belongs not to the package you purged

root@f:~# for i in $(find /etc/mysql); do dpkg -S $i; done
mysql-common, mysql-server-8.0: /etc/mysql
mysql-common: /etc/mysql/my.cnf.fallback
mysql-server-8.0: /etc/mysql/mysql.conf.d
mysql-server-8.0: /etc/mysql/mysql.conf.d/mysql.cnf
mysql-server-8.0: /etc/mysql/mysql.conf.d/mysqld.cnf
mysql-server-8.0: /etc/mysql/debian-start
mysql-common: /etc/mysql/conf.d
mysql-common: /etc/mysql/conf.d/mysql.cnf
mysql-common: /etc/mysql/conf.d/mysqldump.cnf
dpkg-query: no path found matching pattern /etc/mysql/my.cnf
dpkg-query: no path found matching pattern /etc/mysql/debian.cnf
mysql-server-8.0: /etc/mysql/mysql.cnf

And if you purge as you do, only the listed package will be purged

root@f:~# apt purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7
  libevent-pthreads-2.1-7 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl
  libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic
  mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common
  mysql-server-8.0 mysql-server-core-8.0
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 36 not upgraded.
After this operation, 112 kB disk space will be freed.
Do you want to continue? [Y/n]

That means after your manual rm -rf /etc/mysql (again, one should not do this) muliple packages are in a bad state. E.g. mysql-common + mysql-server-8.0 can't differentiate your file removal from an intentional config by the admin. So they have to work with what they find and that is nothing.

Therefore follow on install/upgrades will break.
You manually fixed a little bit of it, but it is worse.

If you really want to purge and remove not only the named, but also the related packages then I'd recommend:
a) list all of them
apt purge mysql-server mysql-client-8.0 mysql-client-core-8.0 ...
# it is a bit of work to collect the list, but the ouput of the purge command will tell you
b) purge with autoremove
$ apt --purge autoremove
$ apt purge mysql-server
# for this you should be sure that formerly nothing was listed for autoremove or you rmight purge more than you wanted

Only now /etc/mysql is almost empty and no package relies on it anymore.
Installing mysql-server now works as there is no old misconfiguration (and rm configfiles is a misconfiguration, just as much as a bad value in a config file) works fine now.

Marking as invalid, as this seems to be a local config issue and not a bug in the package.

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

Thank you for your report.

This looks like a local configuration problem, rather than a bug in Ubuntu.

You can find pointers to get help for this sort of problem here: http://www.ubuntu.com/support/community

Since we use this bug tracker to track bugs in Ubuntu, rather than configuration problems, I'm marking this bug as Invalid. This helps us to focus on fixing bugs in Ubuntu.

If you believe that this is really a bug, then you may find it helpful to read "How to report bugs effectively" http://www.chiark.greenend.org.uk/~sgtatham/bugs.html. We'd be grateful if you would then provide a more complete description of the problem, explain why you believe this is a bug in Ubuntu rather than a problem specific to your system, and then change the bug status back to New.

Changed in mysql-8.0 (Ubuntu):
status: New → Incomplete
Yuan Song (moon396)
Changed in mysql-8.0 (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Yuan Song (moon396) wrote :

/etc/init.d/mysql start does not return even though msyql server runs fine. I can run mysql to connect to the db server.

021-02-17T20:58:31.388560Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23-0ubuntu0.20.04.1) starting as process 362367
2021-02-17T20:58:31.415192Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-17T20:58:32.025870Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-17T20:58:32.101689Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2021-02-17T20:58:32.102024Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
2021-02-17T20:58:32.226743Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-17T20:58:32.226960Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-17T20:58:32.242717Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23-0ubuntu0.20.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu).

Revision history for this message
Yuan Song (moon396) wrote :

Looks like it is an issue of /etc/init.d/mysql. I did not see any error except /etc/init.d/mysql hanged. mysql server runs ok. I compared mysql 5.7 version of /etc/init.d/mysql and the mysql 8 version of /etc/init.d/mysql. Those two files are identical. Should that script be updated?

Revision history for this message
Paride Legovini (paride) wrote :

Hi Yuan, please do not call the /etc/init.d scripts directly, they're not guaranteed to work as one may expect and are in good part a legacy a pre-systemd times. Please use systemctl(1) instead, e.g.:

  $ systemctl status mysql
  $ systemctl stop mysql
  $ systemctl start mysql

and similar.

Changed in mysql-8.0 (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Yuan Song (moon396) wrote :

I stopped mysql server with "systemctl stop mysql" and tried to start it with " systemctl start mysql". Same thing happened. systemctl hanged even though mysql server came up. I can connect to mysql server with no issue.

Changed in mysql-8.0 (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Yuan Song (moon396) wrote :

Here are the steps to recreate the issue.

1. Use the following tutorial to install mysql 5.7 on ubuntu 20.04. Insert some data into the database.
   https://techexpert.tips/mysql/installing-mysql-5-7-ubuntu-20-04/

2. Uninstall mysql-client, mysql-community-server, and mysql-server.
    apt-get remove mysql-community-server mysql-community-client mysql-server mysql-common mysql-client
3. remove /etc/apt/preferences.d/mysql
4. install the default verson of mysql-server.
    apt-get install mysql-server

Revision history for this message
Yuan Song (moon396) wrote :

Looks like there is some environment handling issue during the migration. I found a way to clean up the issue.

1. dpkg -l |grep mysql
2. purge all mysql packages.
3. rm -rf /etc/mysql rm -rf /var/lib/mysql*
4. apt-get install mysql-server. this will work.

Looks like it is the /var/lib/mysql-files directory that caused the hang. It only contained some temporary files that had the following sql.

USE mysql;
INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'auth_socket';
SHUTDOWN;

Changed in mysql-8.0 (Ubuntu):
assignee: nobody → Lars Tangvald (lars-tangvald)
Shaikh Aazar (smaazar)
description: updated
Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

The script in /var/lib/mysql-files seems very old;
We do something similar now, but the "install plugin" line was removed, because that line will return an error if the plugin is already installed, aborting the script before it reaches shutdown, thus causing the installation to hang.

If that file is somehow set to be used it could cause a hang, but it would either need to be specified in the config file (which we've never done automatically) or somehow have the filename postinst expects to find (which we generate with mktemp --tmpdir /var/lib/mysql-files).

So not entirely sure what's happened here.

Bryce Harrington (bryce)
summary: package mysql-server-8.0 8.0.23-0ubuntu0.20.04.1 failed to
- install/upgrade: installed mysql-server-8.0 package post-installation
- script subprocess returned error exit status 1
+ install/upgrade: After installing mysql-8.0 on system that had mysql-5.7
+ removed previously, with error "Can't read dir of '/etc/mysql/conf.d/'"
Bryce Harrington (bryce)
summary: - package mysql-server-8.0 8.0.23-0ubuntu0.20.04.1 failed to
- install/upgrade: After installing mysql-8.0 on system that had mysql-5.7
- removed previously, with error "Can't read dir of '/etc/mysql/conf.d/'"
+ Manually removing /etc/mysql results in install/upgrade failures, with
+ errors like "Can't read dir of '/etc/mysql/conf.d/'"
Changed in mysql-8.0 (Ubuntu):
importance: Undecided → Wishlist
status: Confirmed → Triaged
Revision history for this message
Bryce Harrington (bryce) wrote :

It'd be hard to fix postinst files already on the system to properly deal with the removal of /etc/mysql, but presumably going forward it might be possible to make all the inst scripts not assume its existence.

That there may also be similar issues relating to upgrade from mysql-5.7 to mysql-8.0 is unsurprising, but reading comment #5 onward that seems to me like a separate issue that deserves its own bug report. This report would better focus on the original issue caused by the removal of /etc/mysql.

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.