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?

  • I have a very similar problem. – robguinness Aug 27 '17 at 18:46
up vote 1 down vote accepted

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.

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.