clarkk
clarkk

Reputation: 1

Show mysql replication slave status

How to return the replication server status?

When trying to get the slave status nothing is returned?!

mysql: 5.1.63-0

code

$result = Mysql::result("SHOW SLAVE STATUS");
$status = $result->fetch_assoc();
echo '<pre>';
echo 'result: ';
print_r($result);
echo 'status: ';
print_r($status);
echo '</pre>';

returns

result: mysqli_result Object
(
    [current_field] => 0
    [field_count] => 38
    [lengths] => 
    [num_rows] => 0
    [type] => 0
)
status: 

Upvotes: 2

Views: 1855

Answers (2)

Jeff Barber
Jeff Barber

Reputation: 1

I had the same exact problem and it turned out I was connecting to the master database handle rather than the slave. Your $result shows num_rows=0 so the problem is not how you're fetching the row; it's that there is no status to show.

Upvotes: 0

Gary
Gary

Reputation: 2916

You need to get the row with the data in it:

$row=$result->fetch_assoc()

Then $row['Slave_IO_Running'] and $row ['Slave_SQL_Running'] should give you what you need. Both should be yes.

Upvotes: 4

Related Questions