8

I relocated the mysql folder. I used this link.

I can not start the mysql service and I have this error message

Unit mysql.service has begun starting up.
Aug 26 02:53:19 ubuntu audit[1345]: AVC **apparmor="DENIED**" operation="open" profi                                                 le="/usr/sbin/mysqld" name="/proc/1345/status" pid=1345 comm="mysqld" requested_                                                 mask="r" denied_mask="r" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.505:43): apparm                                                 or="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/1345/status"                                                  pid=1345 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="open" profi                                                 le="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=1345 comm="mysqld" re                                                 quested_mask="r" denied_mask="r" fsuid=109 ouid=0
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="open" profi                                                 le="/usr/sbin/mysqld" name="/proc/1345/status" pid=1345 comm="mysqld" requested_                                                 mask="r" denied_mask="r" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.513:44): apparm                                                 or="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/syste                                                 m/node/" pid=1345 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=109 oui                                                 d=0
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.513:45): apparm                                                 or="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/1345/status"                                                  pid=1345 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="mknod" prof                                                 ile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower-test" pid=1345 comm="mysqld" requ                                                 ested_mask="c" denied_mask="c" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="mknod" prof                                                 ile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower-test" pid=1345 comm="mysqld" requ                                                 ested_mask="c" denied_mask="c" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.661:46): apparm                                                 or="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower                                                 -test" pid=1345 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=109 ouid=                                                 109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.661:47): apparm                                                 or="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower                                                 -test" pid=1345 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=109 ouid=                                                 109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.665:48): apparm                                                 or="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower                                                 -test" pid=1345 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=109 ouid=                                                 109
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="mknod" prof                                                 ile="/usr/sbin/mysqld" name="/ssd/ubuntu.lower-test" pid=1345 comm="mysqld" requ                                                 ested_mask="c" denied_mask="c" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu audit[1345]: AVC apparmor="DENIED" operation="mknod" prof                                                 ile="/usr/sbin/mysqld" name="/ssd/ibdata1" pid=1345 comm="mysqld" requested_mask                                                 ="c" denied_mask="c" fsuid=109 ouid=109
Aug 26 02:53:19 ubuntu kernel: audit: type=1400 audit(1503741199.685:49): apparm                                                 or="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/ssd/ibdata1" pid                                                 =1345 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=109 ouid=109
Aug 26 02:53:20 ubuntu systemd[1]: mysql.service: Main process exited, code=exit                                                 ed, status=1/FAILURE

How can I solve it?

1
  • I have a very similar problem. Commented Aug 27, 2017 at 18:46

3 Answers 3

10

I followed the following steps to change the default data directory in mysql:

I have the configuration of the system as follows

mysql Ver 14.14 Distrib 5.7.19

Ubuntu 16.04 LTS

The steps are as follows:

  1. Stop the mysql server service mysql stop
  2. Edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and edit the datadir field to point to new location.

    For example datadir = /data/mysql

  3. Then copy the content of /var/lib/mysql to new location:

    cp -pr /var/lib/mysql /data
    
  4. Then edit the /etc/apparmor.d/usr.sbin.mysqld file. Remove /var/lib/mysql and add the new datadir location. In my case it is

     # Allow data dir access
     /data/mysql/ r,
     /data/mysql/** rwk,
    
  5. Restart apparmor service systemctl restart apparmor

  6. Restart the mysql service service mysql start

    The above steps worked for me, I hope it will work for you too.

1
1

Always check the Apparmor status

  1. sudo service apparmor status
  2. If it is not active, use journalctl -xe, and verify which profile has problems.
0

This worked for me: Mysql Broken After Apt Upgrade

$ sudo vi /etc/apparmor.d/usr.sbin.mysqld

    ...
      /etc/mysql/mysql.conf.d/ r,
      /etc/mysql/mysql.conf.d/* r,
      /sys/devices/system/node/* r,
      /etc/mysql/*.cnf r,
      /run/mysqld/* rw,
    ...

$ sudo systemctl reload apparmor.service
$ sudo systemctl start mysql.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .