MySQL #6 - Error on delete of './my-database/db.opt' (Errcode: 13 - Permission denied)

If you get this error message when you are trying to drop a MySQL database say my_database then the reason for this is File Permissions (Error code 13).

Whenever we create a database, a directory is created under mysql/var/ ( XAMPP: XAMPP/xamppfiles/mysql/var/) with the same name as that of your database, this directory contains a file called db.opt which contains metadata related to the database.

OK! but Why this error? : All MySQL related files are stored in your filesystem, if you try to DROP the database, the corresponding db.opt, and the DB directory is to be deleted but it may be so that you do not have permissions to delete directories and files.

How can I get Access to delete db.opt file and hence the database:
  1. Locate your database directory.
  2. Check its access permissions
  3. Change it to something like 0777 using CHMOD command recursively.
  4. Now try to run DROP database <database-name>
  5. Things should go right this time!

If your server is located at a remote location you can access it FTP clients and change dir/file permissions using tool options.

Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.