Kiểm tra version mysql cmd

MySQL has gone through several versions over the years, and every version introduces changes to syntax and the way data is stored on your server. Developers need to know the MySQL version so that they can use specific features available with newer versions. Older features might be deprecated and no longer available in newer versions. These issues can create problems in newer applications or after database administrators upgrade to newer versions of MySQL.

Before you can query for the MySQL version, you need access to the command-line terminal and the right permissions to the remote server. You can query the MySQL version in several ways, but the general syntax depends on the operating system.

How to Check Your MySQL Version: Ubuntu

Ubuntu is a Linux distribution popular with developers. It’s one of the more popular Linux distributions for users who are unfamiliar with Linux and want to learn the operating system.

To start the command-line utility, type the following into your terminal:

1

mysqld --version

The above command gets the server version. If you need to know the client application version, use the following command:

1

mysql --version

Output for the command would look similar to the following:

1

/usr/sbin/mysqld  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

How to Check Your MySQL Version: Mac Terminal

Although you probably run MySQL on a Linux distribution or the Windows operating system, you might have a Mac to connect to the server. You can get the version for the MySQL engine by using the Mac terminal in the same way you would use a Linux terminal.

The following command gets the server version in your Mac terminal:

mysqld –version

The above command shows you the server’s version. If you want to see the client version, use the following command:

mysql –version

How to Check Your MySQL Version: Windows

MySQL server runs on the Windows operating system, although it’s more commonly used on Linux distributions. You can install MySQL server on a Windows server and use the client application on a Windows desktop.

The command to check the MySQL server version is the same in Windows as in Linux. The following command sends output to the console listing the server version:

mysqld –version

The client version is shown when you open the MySQL terminal. If you use the shortcut on the Windows menu, the terminal opens and the client version is displayed. The following command will also show you the client version:

mysql -v

Conclusion

Regardless of your client operating system, knowing how to identify the MySQL version running on the database server is a critical part of development. Every major upgrade to a new version of MySQL adds new features, and developers deprecate some functionality. By querying for the database version, you can take advantage of newer features that make applications faster and help developers write more efficient code.

In this tutorial I will explain how to check MySQL version number in different ways. MySQL provides some features for particular version numbers and on particular platforms only. So, in some situations it gets really important to find the MySQL version number installed. If you are faced with such a problem you can use any of the following techniques to find MySQL version number.

I am going to show you how to find MySQL version number using the following tools and techniques:

Please note that these techniques will work on most/all platforms (including Windows, Solaris, Linux etc) where MySQL and clients can be installed. This also includes major Linux distributions like Ubuntu, Centos, Debian, Gentoo etc

Using MySQL client (e.g CLI, Query Browser) to check MySQL version:

If you are using a MySQL client e.g. MySQL command line or Query Browser, you can simply execute the following mysql version query.

SELECT version();

OR

SELECT @@version;

Output:

mysql> SELECT @@version; +------------+ | @@version | +------------+ | 5.0.67-log | +------------+ 1 row in set (0.00 sec) mysql> SELECT VERSION(); +------------+ | VERSION() | +------------+ | 5.0.67-log | +------------+ 1 row in set (0.01 sec)

You can also use the STATUS command in MySQL cli tool to find MySQL version number (output truncated)

mysql> SHOW GLOBAL VARIABLES LIKE '%version%'; . . mysql> STATUS; -------------- mysql Ver 14.12 Distrib 5.0.67, for redhat-linux-gnu (x86_64) using EditLine wrapper . . --------------

Using MySQL Workbench:

You could also use MySQL Workbench to check the version number for MySQL. Once you are connected to a server using MySQL Workbench, click on Server from main menu and then "Server Status" to view the server status (including version).

Kiểm tra version mysql cmd

Using MySQL Administrator (free GUI tool) to check MySQL version:

OR if you have access to MySQL Administrator and you are connected to the server. Just click on "Server Information" on the left side pane. The version information will be displayed on the right side pane.

Kiểm tra version mysql cmd

Using mysqladmin to check MySQL version:

You can also find the version number using mysqladmin command line tool. mysqladmin will also provide you good information about the server e.g. uptime, open tables etc.. Here is how I ran it on my windows machine.

C:\>mysqladmin -uroot -p -hlocalhost version Enter password: ******** mysqladmin Ver 8.42 Distrib 5.1.30, for Win32 on ia32 Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 5.1.30-community Protocol version 10 Connection localhost via TCP/IP TCP port 3306 Uptime: 4 days 22 hours 54 min 31 sec Threads: 3 Questions: 1412 Slow queries: 0 Opens: 537 Flush tables: 1 Open tables: 0 Queries per second avg: 0.3

Using phpMyAdmin:

Click on home icon on the top-left corner of any page or click on "Server:" link at the very top. You should see MySQL server's version number on the right side of the page (something like the image below).

Kiểm tra version mysql cmd

Did this tutorial help a little? How about buy me a cup of coffee?

Kiểm tra version mysql cmd

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.

IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.