Linux : Drop MySQL database return error db.opt Errcode: 13 – Permission denied

By | October 10, 2020

Trying to drop (delete) a MySQL database using CLI and the following error is returned?

ERROR 6 (HY000): Error on delete of ‘./database//db.opt’ (Errcode: 13 – Permission denied)

This is most likely due to permission issue on the database folder or a file within that folder.

Have a look at the MySQL database folder using the following command :

ls -la /var/lib/mysql/

Databases folders should have 750 permissions and owned by the “mysql” user and group, as followed :

drwxr-x---   2 mysql mysql     4096 Aug 17 21:44 mysql

If all database folders have the right permissions, investigate further within the folders for any permissions issues on “.frm”, “.myd”, “.myi”, “.csm”, “.csv” and “.ibd” files. They should have 640 permissions and owned by “mysql” user and group, as followed :

-rw-r----- 1 mysql mysql    9582 Aug 17 21:44 db.frm
-rw-r----- 1 mysql mysql     976 Aug 17 21:44 db.MYD
-rw-r----- 1 mysql mysql    5120 Aug 17 21:44 db.MYI
-rw-r----- 1 mysql mysql      65 Aug 17 21:44 db.opt