Its very easy to check MySQL version via SSH, you just have to enter below command for it.
MySQL -V
You can check description for this here.
For PHP version you can run below command:
php -v
MySQL -V
You can check description for this here.
For PHP version you can run below command:
php -v