0
0
MysqlHow-ToBeginner · 3 min read

How to Check MySQL Version Quickly and Easily

To check the MySQL version, run the SQL command SELECT VERSION(); in your MySQL client. Alternatively, use the command line with mysql --version to see the installed MySQL client version.
📐

Syntax

You can check the MySQL version using a simple SQL query or a command line command.

  • SQL Query: SELECT VERSION(); returns the MySQL server version.
  • Command Line: mysql --version shows the installed MySQL client version.
sql
SELECT VERSION();
💻

Example

This example shows how to get the MySQL server version by running the SQL query inside a MySQL client.

sql
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.32    |
+-----------+
1 row in set (0.00 sec)
Output
+-----------+ | VERSION() | +-----------+ | 8.0.32 | +-----------+ 1 row in set (0.00 sec)
⚠️

Common Pitfalls

Some common mistakes when checking MySQL version include:

  • Running mysql --version inside the MySQL client prompt instead of the system shell.
  • Confusing the MySQL client version with the server version; SELECT VERSION(); shows the server version.
  • Not having MySQL in your system PATH, causing mysql --version to fail.
bash
Wrong (inside MySQL client):
mysql> mysql --version
ERROR: Unknown command

Right (in system shell):
$ mysql --version
mysql  Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)
📊

Quick Reference

MethodCommandDescription
SQL QuerySELECT VERSION();Shows MySQL server version
Command Linemysql --versionShows MySQL client version installed on system

Key Takeaways

Use SELECT VERSION(); inside MySQL to get the server version.
Use mysql --version in the system shell to check client version.
Do not run mysql --version inside the MySQL client prompt.
Server and client versions can differ; check accordingly.
Ensure MySQL is in your system PATH to run command line checks.