When encountering the error “mysqld: can’t create/write to file ‘/var/lib/mysql/is_writable’ (os errno 13 – permission denied)” in MySQL, it indicates that the MySQL server does not have sufficient permissions to create or write to the specified file or directory.
This error can occur due to various reasons, but it commonly happens when the file or directory permissions are incorrect or when the MySQL server is running under a different user than the one with the appropriate write permissions.
To resolve this issue, you can take the following steps:
-
Check and Modify File/Directory Permissions:
- Verify if the file or directory ‘/var/lib/mysql/is_writable’ exists. If it doesn’t exist, create it by using the appropriate MySQL user or the user with necessary write permissions.
-
Ensure that the ownership and permissions of the file or directory are correctly set. The ownership should match the user running the MySQL server, and the permissions should allow write access. For example, you can set ownership to ‘mysql’ user and group, and the permissions to 755 (rwxr-xr-x) using the following command:
sudo chown mysql:mysql /var/lib/mysql/is_writable
sudo chmod 755 /var/lib/mysql/is_writable
-
Check MySQL User Privileges:
-
Verify that the MySQL user running the server has the necessary privileges to create and write to files. You can check the user’s privileges by using the following MySQL command:
SHOW GRANTS FOR 'mysql_user'@'localhost';
-
If the privileges are insufficient, granting appropriate permissions can be done with the following command:
GRANT FILE ON *.* TO 'mysql_user'@'localhost';
Replace ‘mysql_user’ with the actual MySQL user that needs the permissions.
-
Verify that the MySQL user running the server has the necessary privileges to create and write to files. You can check the user’s privileges by using the following MySQL command:
After completing the necessary steps, restart the MySQL server to apply the changes. The error should no longer occur, and the server will be able to create and write to the specified file or directory.
Example:
sudo chown mysql:mysql /var/lib/mysql/is_writable
sudo chmod 755 /var/lib/mysql/is_writable
SHOW GRANTS FOR 'mysql_user'@'localhost';
GRANT FILE ON *.* TO 'mysql_user'@'localhost';