MySQL VERSION() Function

The VERSION() function returns the current version of the MySQL database as a string.


Syntax

VERSION()

Definition and Usage

  • The VERSION() function is used to retrieve the current version of the MySQL server.
  • It provides the version information as a string that includes the full version number, and in some cases, additional details about the server build.
  • This function can be helpful when you need to check compatibility with specific features or troubleshoot version-related issues.

Technical Details

  • Works in: From MySQL 4.0
  • The result returned by the VERSION() function typically includes major, minor, and patch version numbers, and sometimes build information.

Examples

Example 1: Retrieve the MySQL version

SELECT VERSION();

Result:

'8.0.26-0ubuntu0.20.04.2'

The output will show the MySQL version and potentially extra build or operating system-specific information.


Usage Notes

  • If you are upgrading MySQL or working with different versions, the VERSION() function can help you verify the version you are working with.
  • This function is especially useful in scripts that need to check the MySQL version before performing specific operations that require a minimum version.

Was this article helpful?