use mysqlbinlog command can't find file

6.6k views Asked by At

when I use mysqlbinlog command I can't find the file.

 lihaodeMacBook-Pro:data lihao$ mysqlbinlog --start-position=106 --stop-position=125  mysqlbin.000001 > ~/tmp1.sql
    mysqlbinlog: File 'mysql-bin.000001' not found (Errcode: 13)
lihaodeMacBook-Pro:data lihao$ ls -a
        .                            ib_logfile0                  library                      mysql-bin.000001
        ..                           ib_logfile1                  lihaodeMacBook-Pro.local.err mysql-bin.000002
        lihaodeMacBook-Pro:data lihao$ mysqlbinlog /usr/local/mysql-5.1.63-osx10.6-x86_64/data/mysql-bin.000001
        /*!40019 SET @@session.max_insert_delayed_threads=0*/;
        /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
        DELIMITER /*!*/;
        mysqlbinlog: File '/usr/local/mysql-5.1.63-osx10.6-x86_64/data/mysql-bin.000001' not found (Errcode: 13)
3

There are 3 answers

1
Gryfalcon On

I find the solution of the question by myself.I can't find the file because I don't have permission to read or write the file.I can use the command by add sudo at front of the commend.

1
Gaurav Kumar On

Mysql Server 5.7 issue resolved: there are two possibilities over here.

One is either your bin-log file is in /var/log/mysql in that case:

cd /var/log/mysql/

then access the file as sudo user

sudo mysqlbinlog mysql-bin.00000x

if file is in /var/lib/mysql then one needs sudo access to even read the file so follow these two steps:

Login as sudo root user

sudo -i

Once u are sudo user then go to the following directory: (without being a sudo user this location will deny the permission to even enter the directory)

cd /var/lib/mysql/

after that access the file

sudo mysqlbinlog mysql-bin.00000x
0
Godfrey On

In my case it was permission related. Ensure you're sudo when using mysqlbinglong utility.

Should somebody submit an issue to the creators of the mysqlbinlog utility ? The error should be a bit more clear in my opinion.