Bug #28108 mysqlbinlog reports "file not found" when file exists
Submitted: 25 Apr 2007 23:43 Modified: 26 Apr 2007 4:37
Reporter: Ofer Inbar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.0.24 OS:Linux (RHEL 4)
Assigned to: CPU Architecture:Any
Triage: D5 (Feature request)

[25 Apr 2007 23:43] Ofer Inbar
Description:
When mysqlbinlog cannot read a file named on the command line, it reports "File <name> not found" if it cannot read the file, regardless of whether the file actually exists.  This is misleading.  "not found" should indicate there is no file by that name; "cannot read" should be used to indicate it can't read the file (or "cannot open").

How to repeat:
~> mysqlbinlog /var/lib/mysql/binlog.000007 
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
mysqlbinlog: File '/var/lib/mysql/binlog.000007' not found (Errcode: 13)
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

~>ls -l /var/lib/mysql/binlog.000007
-rw-rw----  1 mysql mysql 58166 Apr 25 15:42 /var/lib/mysql/binlog.000007

Suggested fix:
Report "cannot read file <filename>" followed by the error from the system call (which will indicate the reason it cannot read the file).
[26 Apr 2007 4:37] Valeriy Kravchuk
Thank you for a problem report. "not found" message contains exact error code (Errcode: 13). If you try to run

perror 13

you will get:

OS error code 13:  Permission denied

Just the same result that shell will give you. So, what you are asking for is "already there", but presented in a different way. 

I agree that what you are asking for is a reasonable feature request, though.
[22 Oct 2013 17:23] Bill Karwin
The error messages appears to have improved in some recent release. In 5.5.32, it only reports "Errcode: 13" which is confusing for people who don't have errcodes memorized and don't know to use perror to translate errcodes.

In MySQL 5.6.13, it still says "File '%s' not found," which appears to be a fixed error whenever a file open fails, in mysys/my_open.c, and mysqlbinlog calls my_open().

But at least now that error is followed by both the errno and perror message, so the reason ("Permission denied") is more clear.

The following output is from MySQL Community Edition 5.6.13:  

$ ./mysqlbinlog /var/lib/mysql/mysqld-bin.000001 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
./mysqlbinlog: File '/var/lib/mysql/data/mysqld-bin.000001' not found (Errcode: 13 - Permission denied)
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;