hi How can i select just the position value from the 'SHOW MASTER STATUS' query exp something like
select position from (show 开发者_开发问答master status);
thanks for your time and help
Unfortunately, there is no direct table to query that info.
If you use PHP, you can retrieve it as follows:
$sql="SHOW MASTER STATUS";<BR>
$result = mysqli_query($sql);<BR>
$row = mysqli_fetch_assoc($result);<BR>
$pos = $row["Position"];
If you need it via shell scripting you do the following:
POS=\`mysql -h... -u... -p... -A -skip-column-names -e"SHOW MASTER STATUS;" | awk '{print $2}'\`
In Linux you can type the following command in the terminal this will give you the single value of Seconds_Behind_Master.
mysql -h 127.0.0.1 -u root -e 'show slave status\G' | grep 'Seconds_Behind_Master';
In Linux bash script you can try below command through mysql client to get the File and Position
For File:
mysql -u username -p password -h IP -P Port -e "show master status" | grep "File"| cut -d ":" -f2
For Position
mysql -u username -p password -h IP -P Port -e "show master status" | grep "Position"| cut -d ":" -f2
精彩评论