i'm trying to change the datadir in mysql, i created a new directory with the user mysql as a owner, i know am not supposed to set the permission to 777. but even with this full permission still getting the same error in the log file whenever i try to start the mysql service.

[InnoDB] The innodb_system data file 'ibdata1' must be writable

user@user:~$ ls -l /database2/mysql | grep ibdata1 
-rwxrwxrwx 1 mysql mysql 12582912 Jan 15 15:24 ibdata1

any solution ?

  • Are /database2 and /database2/mysql accessible to the mysql user? – mustaccio Jan 15 at 16:11
  • @mustaccio yes, both are owned by the mysql user. – Someone Jan 15 at 16:19
  • And both directories are at least dr-x------? – Rick James Jan 15 at 18:06
  • @RickJames yes, drwxr-xr-x 3 mysql mysql 4096 Jan 15 17:10 database2 – Someone Jan 15 at 18:26
  • @Someone - What OS? Is /database2 mounted? Is SELINUX in effect? – Rick James Jan 15 at 18:30

After reading this article and getting a main idea about SELinux and Apparmor i have finally managed to solve the issue. The solution was adding the new path of my new datadir in /etc/apparmor.d/usr.sbin.mysqld like this:

/database2/ r,
/database2/** rwk,

Now restart the apparmor service and start the mysql service.

sudo systemctl restart apparmor
sudo systemclt start mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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