Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8445519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:40:45+00:00 2026-06-10T09:40:45+00:00

I am trying to recover the content of MySQL binary log file using PHP

  • 0

I am trying to recover the content of MySQL binary log file using PHP from the virtual machine I am running. I am running CentOS on the virtual machine and LAMP.

I have 4 virtual machines running on a virtual network, they are all located on the same subnet and the MySQL databases are up and running and the replication is working.

I am trying to recover the content of the master’s bin log using PHP. Normally the content of the file can be recovered using the following command:

shell> mysqlbinlog [options] log_file

I have written a PHP script that executes a shell command on the local machine:

$cmd="mysqlbinlog /var/lib/mysql/provider-bin.000003";
echo "<pre>".shell_exec($cmd);

I have checked that the provider-bin.000003 exists and that the shell_exec function works and is not disabled.

The problem takes place when I execute the command on the console I get the content of the bin file, but the PHP script does not output the expected result.

It’s outputting the following instead:

/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

Update: exec

I have also tried using the exec function adn it outputs the same:

$cmd="mysqlbinlog /var/lib/mysql/provider-bin.000003";

print_r(exec($cmd,$ret_value)) . "<br />DONE";

echo "<pre>".shell_exec($cmd." 2>&1");

Much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:40:47+00:00Added an answer on June 10, 2026 at 9:40 am

    I have figured it out a couple of days agon, so here is the solution.

    Although mysqlbinlog gets executed by PHP it is still not able to read MySQL’s binary files if run from a browser, for some reason it shows file does not exists. That was never my plan, so a cron job and sh file did the trick for me.

    Cron job will run the script as a root without explosing its content to the outside world.

    Now my circular replication failover script is running happily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to recover a table in a MySQL database from Time Machine, however
I am trying to scrape some content from an HTML page. I'm using libxml2
I'm just trying to recover a file in C on an HFS+ formatted Volumn.
I'm trying to serve a word document (docx) from an asp.net page using the
What i am trying to do is recover data from a table and add
I am trying to test a WCF service using the basichttpbinding endpoint from the
I am trying to recover the movement of a camera by using the fundamental
I've been trying to recover some fonts from an epub created with InDesign. I
I trying to recover some old source code (plain text) from a bunch of
I am trying to recover a value from a cookie, which is somewhere on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.