MySQL Error – ‘ibdata1’ Must Be Writable Despite Full Permissions

MySQLmysqld

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 ?

Best Answer

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