i am not able to install mysql on my system

Asked by arun on 2021-01-30

 i have tried everything in at this question https://stackoverflow.com/questions/50150965/mysql-not-running-after-upgrading-mysql-version/50303051

Mysql was not working then i decided to purge mysql then tried installing this is what all i am getting now.

✗ sudo apt-get --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.32-0ubuntu0.16.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
ERROR: Unable to start MySQL server:
mysqld: Can't read dir of '/etc/mysql/mysql.conf.d/' (Errcode: 13 - Permission denied)
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-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)

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2021-01-30
Last query:
2021-01-30
Last reply:
2021-01-30
Manfred Hampl (m-hampl) said : #1

mysqld: Can't read dir of '/etc/mysql/mysql.conf.d/' (Errcode: 13 - Permission denied)

For dignostic purposes, what is the output of the following commands:

uname -a
lsb_release -crid
apt-cache policy mysql-server-5.7
ls -la /etc/mysql/mysql.conf*

arun (arunwebber) said : #2

➜ ~ uname -a
Linux xxxxx 4.4.0-201-generic #233-Ubuntu SMP Thu Jan 14 06:10:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
➜ ~ lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 16.04.7 LTS
Release: 16.04
Codename: xenial
➜ ~ apt-cache policy mysql-server-5.7
mysql-server-5.7:
  Installed: 5.7.32-0ubuntu0.16.04.1
  Candidate: 5.7.32-0ubuntu0.16.04.1
  Version table:
 *** 5.7.32-0ubuntu0.16.04.1 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     5.7.11-0ubuntu6 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
➜ ~ ls -la /etc/mysql/mysql.conf*
total 16
drwxrwxrwx 2 root root 4096 Jan 30 17:46 .
drwxr-xr-x 4 root root 4096 Jan 30 17:52 ..
-rw-r--r-- 1 root root 3028 Feb 3 2017 mysqld.cnf
-rw-r--r-- 1 root root 21 Feb 3 2017 mysqld_safe_syslog.cnf

Manfred Hampl (m-hampl) said : #3

Do you use apparmor?

What is the output of the commands

dmesg | grep mysql
sudo apparmor_status
cat -n /etc/apparmor.d/usr.sbin.mysqld

arun (arunwebber) said : #4

➜ ~ dmesg | grep mysql
➜ ~ sudo apparmor_status
apparmor module is loaded.
29 profiles are loaded.
29 profiles are in enforce mode.
   /sbin/dhclient
   /usr/bin/evince
   /usr/bin/evince-previewer
   /usr/bin/evince-previewer//sanitized_helper
   /usr/bin/evince-thumbnailer
   /usr/bin/evince//sanitized_helper
   /usr/bin/vidalia
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/NetworkManager/nm-dhcp-helper
   /usr/lib/connman/scripts/dhclient-script
   /usr/lib/cups/backend/cups-pdf
   /usr/lib/lightdm/lightdm-guest-session
   /usr/lib/lightdm/lightdm-guest-session//chromium
   /usr/lib/snapd/snap-confine
   /usr/lib/snapd/snap-confine//mount-namespace-capture-helper
   /usr/lib/telepathy/mission-control-5
   /usr/lib/telepathy/telepathy-*
   /usr/lib/telepathy/telepathy-*//pxgsettings
   /usr/lib/telepathy/telepathy-*//sanitized_helper
   /usr/lib/telepathy/telepathy-ofono
   /usr/sbin/cups-browsed
   /usr/sbin/cupsd
   /usr/sbin/cupsd//third_party
   /usr/sbin/ippusbxd
   /usr/sbin/tcpdump
   docker-default
   system_tor
   webbrowser-app
   webbrowser-app//oxide_helper
0 profiles are in complain mode.
9 processes have profiles defined.
9 processes are in enforce mode.
   /sbin/dhclient (2726)
   /usr/sbin/cups-browsed (1255)
   /usr/sbin/cupsd (1186)
   /usr/sbin/cupsd (1268)
   /usr/sbin/cupsd (1269)
   /usr/sbin/cupsd (1270)
   /usr/sbin/cupsd (1271)
   /usr/sbin/cupsd (1272)
   system_tor (1529)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
➜ ~ cat -n /etc/apparmor.d/usr.sbin.mysqld
     1 # vim:syntax=apparmor
     2 # Last Modified: Tue Feb 09 15:28:30 2016
     3 #include <tunables/global>
     4
     5 /usr/sbin/mysqld {
     6 #include <abstractions/base>
     7 #include <abstractions/nameservice>
     8 #include <abstractions/user-tmp>
     9 #include <abstractions/mysql>
    10 #include <abstractions/winbind>
    11
    12 # Allow system resource access
    13 /proc/*/status r,
    14 /sys/devices/system/cpu/ r,
    15 /sys/devices/system/node/ r,
    16 /sys/devices/system/node/** r,
    17 capability sys_resource,
    18 capability dac_override,
    19 capability dac_read_search,
    20 capability setuid,
    21 capability setgid,
    22
    23 # Allow network access
    24 network tcp,
    25
    26 /etc/hosts.allow r,
    27 /etc/hosts.deny r,
    28
    29 # Allow config access
    30 /etc/mysql/** r,
    31
    32 # Allow pid, socket, socket lock file access
    33 /var/run/mysqld/mysqld.pid rw,
    34 /var/run/mysqld/mysqld.sock rw,
    35 /var/run/mysqld/mysqld.sock.lock rw,
    36 /run/mysqld/mysqld.pid rw,
    37 /run/mysqld/mysqld.sock rw,
    38 /run/mysqld/mysqld.sock.lock rw,
    39
    40 # Allow systemd notify messages
    41 /{,var/}run/systemd/notify w,
    42
    43 # Allow execution of server binary
    44 /usr/sbin/mysqld mr,
    45 /usr/sbin/mysqld-debug mr,
    46
    47 # Allow plugin access
    48 /usr/lib/mysql/plugin/ r,
    49 /usr/lib/mysql/plugin/*.so* mr,
    50
    51 # Allow error msg and charset access
    52 /usr/share/mysql/ r,
    53 /usr/share/mysql/** r,
    54
    55 # Allow data dir access
    56 /var/lib/mysql/ r,
    57 /var/lib/mysql/** rwk,
    58
    59 # Allow data files dir access
    60 /var/lib/mysql-files/ r,
    61 /var/lib/mysql-files/** rwk,
    62
    63 # Allow keyring dir access
    64 /var/lib/mysql-keyring/ r,
    65 /var/lib/mysql-keyring/** rwk,
    66
    67 # Allow log file access
    68 /var/log/mysql.err rw,
    69 /var/log/mysql.log rw,
    70 /var/log/mysql/ r,
    71 /var/log/mysql/** rw,
    72
    73 # Allow read access to OpenSSL config
    74 /etc/ssl/openssl.cnf r,
    75 # Site-specific additions and overrides. See local/README for details.
    76 #include <local/usr.sbin.mysqld>
    77 }
➜ ~

Manfred Hampl (m-hampl) said : #5

I am sorry, I cannot see anything wrong.

Please run the command

sudo dpkg --configure -a

and copy/paste its output, to see whether it produces the same output as before.

arun (arunwebber) said : #6

i got this
Setting up mysql-server-5.7 (5.7.32-0ubuntu0.16.04.1) ...
Setting up mysql-server (5.7.32-0ubuntu0.16.04.1) ...
what is the problem?

Best Manfred Hampl (m-hampl) said : #7

Whatever it was, this shows that the installation went ok.
Is your problem solved?

arun (arunwebber) said : #8

Thanks Manfred Hampl, that solved my question.