Atlantic.Net Blog

How to Check the MySQL Version in Linux

MySQL is one of the most popular open-source database management systems and is used by many websites and organizations. There are a lot of MySQL versions available on the Internet. If you want to host an application that requires a specific MySQL version, you will need to know the version of MySQL installed on your server.

In this post, we will show you how to check the MySQL version in Linux.

Check the MySQL Version via Command Line

The simple and easiest way to check the MySQL version on your system is from the command line. If you have root access to your Linux server, you can use the following command to check the MySQL version:

mysql -V

You will get the MySQL version in the following output:

mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

MySQL also provides a MySQLAdmin command-line utility to perform several administrative tasks. You can also use this utility to check the MySQL version:

mysqladmin -V

You will get the following output:

mysqladmin  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Also Read

How to Check and Repair MySQL

Check MySQL Version Using SHOW VARIABLES

You can also use the MySQL command-line utility to check the MySQL version.

First, connect to the MySQL server with the following command:

mysql -u root -p

Once you are connected, use the following command to check the MySQL version:

mysql> SHOW VARIABLES LIKE '%version%';

You will get the MySQL version in the following output:

+--------------------------+-------------------------------+
| Variable_name            | Value                         |
+--------------------------+-------------------------------+
| admin_tls_version        | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |
| immediate_server_version | 999999                        |
| innodb_version           | 8.0.26                        |
| original_server_version  | 999999                        |
| protocol_version         | 10                            |
| replica_type_conversions |                               |
| slave_type_conversions   |                               |
| tls_version              | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |
| version                  | 8.0.26                        |
| version_comment          | Source distribution           |
| version_compile_machine  | x86_64                        |
| version_compile_os       | Linux                         |
| version_compile_zlib     | 1.2.11                        |
+--------------------------+-------------------------------+

Also Read

How to Create and Delete User in MySQL

Check MySQL Version Using SELECT VERSION

After connecting to the MySQL server, you can also use the SELECT VERSION command to check the MySQL version.

mysql> SELECT VERSION();

You will get the following output:

+-----------+
| VERSION() |
+-----------+
| 8.0.26    |
+-----------+
1 row in set (0.00 sec)

Check MySQL Version Using STATUS

You can also run the STATUS query inside the MySQL shell to check the MySQL version:

mysql> STATUS;

You will get the following output:

--------------
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Connection id:		11
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.26 Source distribution
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/lib/mysql/mysql.sock
Binary data as:		Hexadecimal
Uptime:			2 min 12 sec

Threads: 2  Questions: 17  Slow queries: 0  Opens: 150  Flush tables: 3  Open tables: 66  Queries per second avg: 0.128
--------------

Check MySQL Version Using PHP

If your application is hosted on the shared hosting and doesn’t have access to the command line, you can upload the PHP file to your website directory and check the MySQL version.

To check the MySQL version using PHP, create a file named info.php with the following content and upload it to your website directory:

<?php

// Create a database connection.
$link = mysqli_connect("localhost", "root", "securepassword");

// Print the MySQL version.
echo mysqli_get_server_info($link);

// Close the connection.
mysqli_close($link);

Next, open your web browser and access info.php file using the URL http://your-website-name/info.php. This will display the MySQL version on your web browser screen.

Conclusion

In this post, we explained several methods to find out the MySQL version in your Linux system. You can now choose your preferred method to check the MySQL version. Try MySQL on VPS hosting from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year