6

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

miken32
  • 42,008
  • 16
  • 111
  • 154
Khaled_Jamel
  • 101
  • 2
  • 9

3 Answers3

6

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}'\`
miken32
  • 42,008
  • 16
  • 111
  • 154
RolandoMySQLDBA
  • 43,883
  • 16
  • 91
  • 132
  • thank you, thank you, thank you Rolando i am writing a shell scipt so i tryed the shell command and and it give me what i am looking for just a small correction in the command for other vesitor (--skip-column-names) – Khaled_Jamel Mar 07 '11 at 19:46
0

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';
Makyen
  • 31,849
  • 12
  • 86
  • 121
Sanaullah
  • 11
  • 1
  • 1
  • 3
0

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
Andronicus
  • 25,419
  • 17
  • 47
  • 88