How to Check the MySQL Version

By 

Updated on

4 min read

Check MySQL Version

Knowing which MySQL version is running on your server is important when installing applications that require a specific version, troubleshooting compatibility issues, or planning an upgrade.

This guide shows several ways to check the MySQL or MariaDB version from the command line, the MySQL shell, and PHP.

From the Command Line

If you have SSH access to the server, you can check the MySQL version without opening the MySQL shell.

The mysqld binary is the MySQL server process. To display its version, run:

Terminal
mysqld --version
output
/usr/sbin/mysqld  Ver 8.4.3 for Linux on x86_64 (MySQL Community Server - GPL)

The mysql command-line client reports the client version when called with --version or -V:

Terminal
mysql --version
output
mysql  Ver 8.4.3 for Linux on x86_64 using  EditLine wrapper

The mysqladmin utility provides version information as well:

Terminal
mysqladmin -u root -p version
output
Server version          8.4.3
Protocol version        10
Connection              Localhost via UNIX socket

From the MySQL Shell

When you connect to the MySQL shell, the server version is printed in the welcome message:

Terminal
mysql -u root -p
output
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.4.3 MySQL Community Server - GPL

For a quick version check inside the shell, use the SELECT VERSION() statement:

Terminal
SELECT VERSION();
output
+-----------+
| VERSION() |
+-----------+
| 8.4.3     |
+-----------+
1 row in set (0.00 sec)

To see more detailed version information, query the version variables:

Terminal
SHOW VARIABLES LIKE '%version%';
output
+--------------------------+-------------------------------+
| Variable_name            | Value                         |
+--------------------------+-------------------------------+
| innodb_version           | 8.4.3                         |
| protocol_version         | 10                            |
| replica_type_conversions |                               |
| tls_version              | TLSv1.2,TLSv1.3              |
| version                  | 8.4.3                         |
| version_comment          | MySQL Community Server - GPL  |
| version_compile_machine  | x86_64                        |
| version_compile_os       | Linux                         |
+--------------------------+-------------------------------+
8 rows in set (0.00 sec)

The STATUS command also displays the server version along with connection and uptime information:

Terminal
STATUS;

Using PHP

If you do not have command-line access to the server, you can check the MySQL version using a PHP script. Upload the following file to your website document root using FTP or SFTP :

mysql-version.phpphp
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
echo mysqli_get_server_info($link);
mysqli_close($link);

Replace my_user and my_password with an actual MySQL user account . Open the file in your browser and the MySQL version will be displayed:

output
8.4.3
Warning
Remove this file from your server after use. Leaving database credentials in a publicly accessible file is a security risk.

Quick Reference

MethodCommand
Server binarymysqld --version
Client binarymysql --version
mysqladminmysqladmin -u root -p version
MySQL shell (quick)SELECT VERSION();
MySQL shell (detailed)SHOW VARIABLES LIKE '%version%';
MySQL shell (status)STATUS;
PHPmysqli_get_server_info($link)

Troubleshooting

mysqld: command not found
The MySQL server binary is not in your PATH. Try the full path, typically /usr/sbin/mysqld --version, or install the MySQL server package if it is not installed.

mysql: command not found
The MySQL client is not installed. Install it with sudo apt install mysql-client on Ubuntu and Debian, or sudo dnf install mysql on Fedora and RHEL.

Access denied when using mysqladmin
You need to provide valid credentials. Use mysqladmin -u root -p version and enter the password when prompted.

FAQ

How do I tell if I am running MySQL or MariaDB?
Run mysql --version or SELECT VERSION(); from the MySQL shell. MariaDB includes “MariaDB” in the version string (e.g., 10.11.6-MariaDB), while MySQL shows “MySQL Community Server” or similar.

Does SELECT VERSION() show the client or server version?
It shows the server version. The mysql --version command shows the client version, which may differ from the server.

What is the difference between mysql and mysqld?
mysql is the command-line client used to connect to the server and run queries. mysqld is the server process (daemon) that manages the databases.

Conclusion

You can check the MySQL version from the command line with mysqld --version or mysql --version, from the MySQL shell with SELECT VERSION(), or through PHP with mysqli_get_server_info(). For related tasks, see our guides on managing databases and users and listing databases .

If you have any questions, feel free to leave a comment below.

Tags

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page