You can use dpkg to get this information:
dpkg -l mysql-server | grep -E "^ii" | tr -s ' ' | cut -d' ' -f3
This will give you the installed version of the mysql-server package.
If the package is not installed, it will print "No packages found according to the mysql server." instead of this.
source share