How to check the MySQL version on Linux

What is the version of MySQL are you using?

You would quickly say 7 or 8. It is absolutely correct. But, Oracle releases minor versions of MySQL periodically to fix compatibility, performance issue, bug fix, etc.

Just take an example, the current version of MySQL is 8.0.33 released on April 18, 2023. Here, the major version is 8 while 0.33 is a minor release version.

Now, how to find out the exact version of MySQL you are using?

MySQL, in brief

MySQL is one of the most widely-used open-source relational database management systems (RDBMS), integral to many web applications. The Swedish company MySQL AB developed the MySQL database and is now owned by Oracle Corporation.

The initial release was on May 23, 1995, and now the latest stable version is 8.0.33 released on Apr 18, 2023.

Known for its robustness, speed, and compatibility with major operating systems, MySQL forms a key component of the LAMP technology stack (Linux, Apache, MySQL, PHP/Perl/Python) and backbone database for WordPress, Joomla, Drupal, and many more.

Why you should know the exact version of MySQL?

Knowledge of the MySQL version is a key part to manage and maintain the database environment effectively. It’s a fundamental part of your technical knowledge that aids in troubleshooting, performance optimization, security maintenance, and future planning.

These are some of the reasons to know the MySQL Version,

  • Compatibility: Software applications often have specific requirements or limitations based on the version of MySQL.
  • Security: Newer versions of MySQL usually come with security improvements and fixes for vulnerabilities discovered in previous versions.
  • Performance Optimization: Different versions of MySQL may have different performance characteristics.
  • Troubleshooting: For troubleshooting MySQL server problem. Some issues might be specific to certain versions.
  • Upgrade Planning: Essential for upgrade planning, as it allows you to assess changes, improvements, and potential deprecated features between your current version and the intended upgrade.

Finding the MySQL version

There are multiple methods to find out the MySQL version. You can use commands (Terminal) as well as GUI for this purpose. Let’s explore all these methods one by one.

Starting with command line methods first. System Administrators/Linux users prefer the command line method due to their speed and the fact that they work on almost any system, regardless of the graphical capabilities or interface.

They also work remotely over an SSH connection.

Method 1: Using the MySQL Command-Line Tool

The easiest way to check the MySQL version is by using the MySQL command-line client. Open the Linux terminal. Connect to the MySQL server using the following command.

mysql -u username -p

Replace ‘username’ with your MySQL username.

sudo mysql -u imaginelinux -p
Enter password: 

Enter your password. After authentication, you will be greeted with the MySQL monitor as shown below.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.33-0ubuntu0.22.04.2 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
MySQL Monitor Banner

Locate the line saying server version. It should look something like this:

Server version: 8.0.33-0ubuntu0.22.04.2 (Ubuntu)

Here, the “8.0.33” in this line denotes the MySQL version, and ubuntu0.22.04.2 (Ubuntu) shows the Ubuntu Linux version.

Method 2: Use the ‘mysql’ Command With ‘-V’ Option to know the version

Another quick way to determine the MySQL version is by using the ‘-V’ option along with the ‘mysql’ command:

mysql -V

This command displays the version of the MySQL client, and it usually corresponds to the server version.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.33-0ubuntu0.22.04.2 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
output of mysql -v

Method 3: Querying the ‘version()’ SQL Function

If you’re already inside the MySQL monitor, you can simply use the version() function to check your MySQL version.

Open the Linux terminal. Connect to the MySQL server as mentioned earlier.

Run the following SQL query:

SELECT version();
--------------
select version()
--------------

+-------------------------+
| version()               |
+-------------------------+
| 8.0.33-0ubuntu0.22.04.2 |
+-------------------------+
1 row in set (0.00 sec)

This command returns the MySQL version.

Output of MySQL Select Version Query

Method 4: Checking the ‘mysqld’ Command

The ‘mysqld’ command also provides version details. Run the following command in your terminal:

mysqld --version
/usr/sbin/mysqld  Ver 8.0.33-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))

This command displays the MySQL server version similar to the ‘mysql -V’ command.

Method 5: Inspecting MySQL Variables

Finally, you can inspect MySQL’s system variables to find out its version. This is especially handy if you’re already logged into the MySQL server and working with queries:

Connect to the MySQL server as described.

Run the following SQL query:

SHOW VARIABLES LIKE "%version%";
--------------
SHOW VARIABLES LIKE "%version%"
--------------

+--------------------------+-------------------------+
| Variable_name            | Value                   |
+--------------------------+-------------------------+
| admin_tls_version        | TLSv1.2,TLSv1.3         |
| immediate_server_version | 999999                  |
| innodb_version           | 8.0.33                  |
| original_server_version  | 999999                  |
| protocol_version         | 10                      |
| replica_type_conversions |                         |
| slave_type_conversions   |                         |
| tls_version              | TLSv1.2,TLSv1.3         |
| version                  | 8.0.33-0ubuntu0.22.04.2 |
| version_comment          | (Ubuntu)                |
| version_compile_machine  | x86_64                  |
| version_compile_os       | Linux                   |
| version_compile_zlib     | 1.2.13                  |
+--------------------------+-------------------------+
13 rows in set (0.16 sec)

This command displays a list of all MySQL system variables that have ‘version’ in their name. Look for the ‘version’ row in the output, and that should show the MySQL version.

MySQL SHOW VARIABLES LIKE "%version%" output

Check MySQL Version using Graphical Methods

GUI-Based Methods are generally preferred by users who are less comfortable with command-line interfaces, and they often provide additional tools for managing and configuring the MySQL server.

  1. phpMyAdmin: phpMyAdmin is a popular tool for managing MySQL databases over the web. Once you log in to phpMyAdmin, the version is displayed on the main page in the right-hand panel under the ‘Database server’ section.
  2. MySQL Workbench: MySQL Workbench is a comprehensive tool used for database design, modeling, and maintenance, among other tasks. After opening the MySQL Workbench, connect to the desired database. Then go to ‘Server’ on the main menu and select ‘Server Status’. The version of MySQL is listed under ‘Server Information’.
  3. HeidiSQL: HeidiSQL, another graphical tool for managing MySQL servers, shows the MySQL version in the ‘Host’ tab after you’ve logged into the database server.

Conclusion

In conclusion, knowing the MySQL version running on your Linux server is essential for efficient database management. The methods above offer a variety of ways to check this, from quick command-line options to SQL queries to GUI.

Remember, whichever method you choose depends on your level of comfort with command-line or GUI tools, and whether you’re working directly on the server or over a network connection.

All of these methods will provide you with the version of MySQL currently running on the server. select the method that works best for your situation, and maintain a solid grasp of your MySQL environment.

Check this link for the latest MySQL Version and documentation- https://dev.mysql.com/doc/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top