If you have the mysql client installed, you can use it to connect to the database server and issue the following statement:
SELECT VERSION();
For example, you can use this:
echo SELECT VERSION() | mysql -u foo ...other parameters here...
The result will look something like this:
VERSION ()
5.1.41-community
source
share