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


Posted on : Mon, 12th Oct 15 02:17 pm UTC
2314 votes

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

Whenever we crate 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 maybe so that you do not have permissions to delete directories and files.

Error on delete db.opt Errcode 13 Permission denied


Error on delete db.opt Errcode 13 Permission denied

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.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +