Easy as pie:

% mysql --version
mysql  Ver 14.14 Distrib 5.5.30, for Linux (x86_64) using readline 6.2
% mysql --version | cut -d " " -f 6 | cut -d "," -f 1
5.5.30