AppArmor parser error for mysqld

Tags:

Answer: 1

35 hours ago

I have tried to change the MySQL Data Directory to a New Location.

Therefore I have changed the MySQL configuration file

/etc/mysql/mysql.conf.d/mysqld.cnf

and the apparmor file

/etc/apparmor.d/usr.sbin.mysqld

Unfortunately it did not work and I got the following error:

mysqld: Can't change dir to '/new/dir/mysql/' (Errcode: 13 - Permission denied)

I reinstalled both mysql and apparmor. Since then not even apparmor does work anymore. I get the following messages:

Error-messages:

root@Server:~# systemctl status apparmor.service
● apparmor.service - LSB: AppArmor initialization
   Loaded: loaded (/etc/init.d/apparmor; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-08-24 09:24:24 CEST; 1min 41s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19955 ExecStart=/etc/init.d/apparmor start (code=exited, status=123)

Aug 24 09:24:24 Server apparmor[19955]: AppArmor parser error for /etc/apparmor.d/usr.lib.dovecot.dict in /etc/apparmor.d/abstractions/nameservice at line 16: missing an end of line character? (entry: /usr/share/mysql/charsets/*.xml)
Aug 24 09:24:24 Server apparmor[19955]: AppArmor parser error for /etc/apparmor.d/usr.lib.snapd.snap-confine.real in /etc/apparmor.d/usr.lib.snapd.snap-confine.real at line 11: Could not open '/var/lib/snapd/apparmor/snap-confine'
Aug 24 09:24:24 Server apparmor[19955]: AppArmor parser error for /etc/apparmor.d/usr.sbin.dovecot in /etc/apparmor.d/abstractions/nameservice at line 16: missing an end of line character? (entry: /usr/share/mysql/charsets/*.xml)
Aug 24 09:24:24 Server apparmor[19955]: Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
Aug 24 09:24:24 Server apparmor[19955]: AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/abstractions/winbind at line 13: missing an end of line character? (entry: /usr/share/mysql/charsets/*.xml)
Aug 24 09:24:24 Server apparmor[19955]:    ...fail!
Aug 24 09:24:24 Server systemd[1]: apparmor.service: Control process exited, code=exited status=123
Aug 24 09:24:24 Server systemd[1]: Failed to start LSB: AppArmor initialization.
Aug 24 09:24:24 Server systemd[1]: apparmor.service: Unit entered failed state.
Aug 24 09:24:24 Server systemd[1]: apparmor.service: Failed with result 'exit-code'.

I have tried to fix those errors for hours. But now I don't have any clue anymore. Any suggestions what could be the problem?

EDIT: Content of the usr.sbin.mysqld-file

cat /etc/apparmor.d/usr.sbin.mysqld

# vim:syntax=apparmor
# Last Modified: Tue Feb 09 15:28:30 2016
#include <tunables/global>

/usr/sbin/mysqld flags=(complain) {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/user-tmp>
  #include <abstractions/mysql>
  #include <abstractions/winbind>

# Allow system resource access
  /sys/devices/system/cpu/ r,
  capability sys_resource,
  capability dac_override,
  capability setuid,
  capability setgid,

# Allow network access
  network tcp,

  /etc/hosts.allow r,
  /etc/hosts.deny r,

# Allow config access
  /etc/mysql/** r,

# Allow pid, socket, socket lock file access
  /var/run/mysqld/mysqld.pid rw,
  /var/run/mysqld/mysqld.sock rw,
  /var/run/mysqld/mysqld.sock.lock rw,
  /run/mysqld/mysqld.pid rw,
  /run/mysqld/mysqld.sock rw,
  /run/mysqld/mysqld.sock.lock rw,

# Allow execution of server binary
  /usr/sbin/mysqld mr,
  /usr/sbin/mysqld-debug mr,

# Allow plugin access
  /usr/lib/mysql/plugin/ r,
  /usr/lib/mysql/plugin/*.so* mr,

# Allow error msg and charset access
  /usr/share/mysql/ r,
  /usr/share/mysql/** r,

# Allow data dir access
  /var/lib/mysql/ r,
  /var/lib/mysql/** rwk,

# Allow data files dir access
  /var/lib/mysql-files/ r,
  /var/lib/mysql-files/** rwk,

# Allow keyring dir access
  /var/lib/mysql-keyring/ r,
  /var/lib/mysql-keyring/** rwk,

# Allow log file access
  /var/log/mysql.err rw,
  /var/log/mysql.log rw,
  /var/log/mysql/ r,
  /var/log/mysql/** rw,

  # Site-specific additions and overrides. See local/README for details.
  #include <local/usr.sbin.mysqld>
}
Added by: Quinten Walsh

Answer: 2

31 hours ago

A complete removal of all mysql related data was the solution for me to make Apparmor work again.

Additional to removing mysql,

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

I deleted the following folder/files:

rm -rf /etc/apparmor.d/abstractions/mysql 
rm -rf /etc/apparmor.d/cache/usr.sbin.mysqld 
rm -rf /etc/mysql 
rm -rf /var/lib/mysql 
rm -rf /var/log/mysql* 
rm -rf /var/log/upstart/mysql.log* 
rm -rf /var/run/mysqld 
rm -rf ~/.mysql_history

This prompted me the following errors:

    Aug 24 10:29:37 Server apparmor[14061]: AppArmor parser error for /etc/apparmor.d/usr.lib.dovecot.auth in /etc/apparmor.d/usr.lib.dovecot.auth at line 18: Could not open 'abstractions/mysql'
    Aug 24 10:29:37 Server apparmor[14061]: AppArmor parser error for /etc/apparmor.d/usr.lib.dovecot.dict in /etc/apparmor.d/usr.lib.dovecot.dict at line 16: Could not open 'abstractions/mysql'
    Aug 24 10:29:37 Server apparmor[14061]: AppArmor parser error for /etc/apparmor.d/usr.sbin.dovecot in /etc/apparmor.d/usr.sbin.dovecot at line 19: Could not open 'abstractions/mysql'
    Aug 24 10:29:37 Server apparmor[14488]: AppArmor parser error for /etc/apparmor.d/sbin.syslog-ng in /etc/apparmor.d/sbin.syslog-ng at line 22: Could not open 'abstractions/mysql'

After I deleted #include <abstractions/mysql> in the corresponding files, I could start Apparmor again.

Added by: Garett Smitham

Answer: 3

3 hours ago

i removed apparmor and many other things connected to snap got uninstalled .... yet what answered my problem was two simple command.

sudo dpkg-reconfigure mysql-server-5.7

This shall give you some output to follow, however before you purge anything, try the next command if your problem is logging in to mysql.

mysql -u root -p

[adding the -p to the command mysql -u root ended my sorrows i wish i had not purged apparmor]

Added by: Waino DuBuque

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9