mysqld cannot create binlog.index: OS errno 13, Permission denied
mysqld: File '.\binlog.index' not found (OS errno 13 - Permission denied)Short answer
Errno 13 means the account that started mysqld may not write in the data directory. binlog.index is just one of the files the server must create there, because binary logging is on by default and its files live in that directory. Fix access to the whole data directory, start the server the way the manual's Windows reset procedure describes, and check security software.
Fix it fast
1Find out which cause you have
Read the last lines of the error log. It sits in the data directory and is named after the host. Note whether files other than binlog.index are refused too.
tail host_name.err # on Windows, open host_name.err in the data directory with a text editor2Match what you see, then jump to its fix
- 1
Permission denied for binlog.index and for other files in the same data directoryThe data directory is not owned by, or not open to, the account that starts mysqldFix - 2
The MySQL service starts fine, and the error only appears when you run mysqld yourself from a consoleA one-off start for a password reset skipped the steps of the Windows procedureFix - 3
Ownership and permissions are correct and errno 13 still appearsSecurity software blocks mysqld from the data directoryFix
- 1
What does the error look like?
mysqld: File '.\binlog.index' not found (OS errno 13 - Permission denied)Errcode 13 (Permission denied)
Cause 1 of 3
The data directory is not owned by, or not open to, the account that starts mysqld
1Check
Binary logging is on by default in MySQL 8.4 and the binary log files and index go into the data directory, so binlog.index is one of the files the server must create there. The manual says Errcode 13 means the privileges of the data directory or its contents do not permit server access. A server once started as root can leave root-owned files in the data directory, and the normal server account cannot use those.
# Linux or macOS; use your own data directory path
ls -la /usr/local/mysql/var2Fix
Give the account that runs mysqld ownership of the data directory and everything in it. Do not solve it by running the server as root. On Windows, change the permissions of the data folder and its contents so that the account that starts mysqld may use them.
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/var3Verify
Start the server again and connect to it.
mysql -u root -p -e "SELECT CURRENT_USER();"Confirmed by dev.mysql.com
Cause 2 of 3
A one-off start for a password reset skipped the steps of the Windows procedure
1Check
The manual's Windows procedure for resetting the root password begins with logging on to the system as Administrator. For a server installed with the installer it also passes the real option file with --defaults-file, so that the server uses the data directory from that file. A server started without both can end up with a data directory it may not write.
cd "C:\Program Files\MySQL\MySQL Server 8.4\bin"
dir "C:\ProgramData\MySQL\MySQL Server 8.4\my.ini"2Fix
Stop the service first. Then, logged on as Administrator, start mysqld with the option file and the init file, as the manual shows, and delete the init file afterwards. Stop that server and start the service normally.
mysqld --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 8.4\\my.ini" --init-file=C:\\mysql-init.txt3Verify
After the restart as a service, log in with the new password.
mysql -u root -p -e "SELECT CURRENT_USER();"Confirmed by dev.mysql.com
Cause 3 of 3
Security software blocks mysqld from the data directory
1Check
The manual warns that MySQL can fail to start, even with correct ownership, when other security software manages application access to parts of the file system.
tail host_name.err
# on Windows, open host_name.err in the data directory with a text editor2Fix
Reconfigure that software so that mysqld may use the directories it needs in normal operation. Then start the server again.
NET START mysqld_service_name3Verify
The server starts and binlog.index appears in the data directory.
dir "C:\path\to\data" | findstr /i "binlog"Confirmed by dev.mysql.com
How do I stop it coming back?
- Run MySQL as a service, and avoid launching mysqld by hand except for recovery.
- When you start the server as root on Linux, always add --user=mysql, so it creates no root-owned files in the data directory.
- Keep the data directory path in the option file, and point one-off commands at that file with --defaults-file.
- Keep the data directory and all its files owned by the one account that runs the server.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
MySQL root password reset fails: skip-grant-tables will not run ALTER USER
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
A server started with --skip-grant-tables does not read the grant tables, so account statements like ALTER USER are refused until you run FLUSH PRIVILEGES.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fix