Kiểm tra version mysql

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

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

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

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

Kiểm tra version mysql

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.

Your database more than likely runs on MySQL or its fully open-source fork MariaDB. These popular database management software power 90% of websites, so your server host has probably installed either of them for you.

But not all hosts will continue to keep it up to date, so it’s often up to you to check your MySQL version and keep it upgraded. Outdated software on your server is never good and can also be harmful.

Let’s learn how to check if your MySQL version is up to date, and upgrade it if it isn’t.

Watch Our Video Guide to Checking and Upgrading Your MySQL Version

Why Keep MySQL Up to Date?

Manual server maintenance is not a fun task, especially if you’re not very familiar with your webserver’s inner workings. As long as your server and database are working fine, it may be tempting to ignore an outdated piece of software. But there are quite a few reasons why this is a bad idea.

It’s never good to have outdated software on your server. Even the tiniest hole in your security could be a vector for attackers to slip through and take over.

Need to give a shoutout here. Kinsta is amazing, I use it for my personal website. The support is rapid and outstanding, and their servers are the fastest for WordPress.

Kiểm tra version mysql
Phillip Stemann
View plans

They may even be able to mess with your database. All sorts of important info are stored there, such as your WordPress posts and all other kinds of sensitive bits. You don’t want anyone unwanted to be able to modify that.

Besides that, a new version means new features and general improvements for what’s already there. Even if these extra features don’t affect you, more recent MySQL versions are more secure, better optimized, and faster.

Kiểm tra version mysql
What’s new in MySQL 8.0.

And with every update of MySQL comes a whole slew of bug fixes, patching up errors that could be an annoyance at best or cause you serious trouble at worst.

When it comes to any software on your website, it’s almost always best to keep it at the latest version.

MySQL runs in the background of 90% of websites 😲... but not all hosts will continue to keep it updated. Learn how to check for yourself right here ⬇️Click to Tweet

Which Version of MySQL is the Best?

Many servers these days are still running on MySQL 5.7 (the latest version before the jump to 8.0), even though a newer and better version exists. Why is this? And which is best, MySQL 5.7 or 8.0?

Most people don’t upgrade because either they don’t know about the latest MySQL version, or they don’t want to take the time to update it. In addition, 5.7 has not been deprecated and will not be until 2023.

Kiểm tra version mysql
Support EOL for macOS v10.14

But while MySQL 5.7 is still supported, making the switch to the latest version is definitely worth your time. It’s faster and more secure — changes can be observed instantly upon activating it. And for developers who can make use of the new functions, the benefits are more numerous than can be quickly listed.

There are some upgrade considerations and backward incompatibilities you’ll need to know about, but for a majority of sites, they won’t cause issues.

It’s almost always best to keep up with the latest stable version of MySQL. Even minor updates are worth the trouble, though the new built-in auto-updater will likely handle those for you. As for major updates, it’s worth it unless crucial parts of your server are incompatible.

While WordPress supports MySQL versions all the way back to 5.6, 8.0 works perfectly with it. And as 5.6 is no longer supported and is susceptible to bugs and security risks, you should at least update to 5.7.

How to Check MySQL Version

It’s crucial to keep MySQL up to date, but you need to know its version before upgrading. Chances are, you’re already using the latest version and don’t need to do anything at all. There are several ways to check; these are just a handful of the easiest ones.

Check MySQL Version with MyKinsta

Accessing your database and checking your MySQL version with MyKinsta is very easy. There are several ways to do so, as detailed above, but the easiest two are using phpMyAdmin or connecting with the command line.

You can find phpMyAdmin after logging into MyKinsta. Just go to Sites > Info, and under the Database access section, click Open phpMyAdmin. The credentials you need to log in are right there.

You can also connect with the command line with SSH. With Kinsta, we set up everything for you to allow SSH access. Just find your credentials in Sites > Info in the SFTP/SSH section. Then follow the steps below to log in and put in the proper commands.

Use the Command Line

The easiest way to obtain your MySQL version is with a simple code submitted through the command line. It takes mere seconds and answers your question instantly. Getting at your server’s command line shouldn’t be too difficult unless you’re using minimal hosting.

There are a variety of ways to access your server’s command line. For example, your web host may provide a way to submit commands through their back end, such as with cPanel. Or you may be able to use the built-in Terminal or Command Prompt to connect to your server. Tools like PuTTY also exist to help you log in and are usually required for Windows users to connect with SSH.

Either way, you’ll need some SSH login credentials. You can usually find them in your web hosting dashboard, or you can email them and ask for help.

Once you know how you’re going to connect to your server’s command line, follow these steps.

Step 1: Launch the Terminal (Linux, macOS) or Command Prompt/PuTTY (Windows) on your computer. In cPanel, you can find it under Advanced > Terminal.

Kiểm tra version mysql
cPanel Terminal view

Step 2: Provide your SSH credentials to connect and log in to the server.

Step 3: Input the following command:

mysql -V

If you have the MySQL Shell installed, you can also use the simple command “mysql” to show your version information.

Either way, the version number should be output on the screen.

Check MySQL Version with phpMyAdmin

There’s another straightforward way to check your MySQL version, and that’s with phpMyAdmin. This software is also ubiquitous and present on most servers, so you have a good shot at finding your MySQL version.

Find your phpMyAdmin credentials by checking your web hosting dashboard. There may even be a direct link to log in there. Email your host if you can’t find them.

Log in to phpMyAdmin once you find your credentials. As soon as you’re in, you’ll see a Database server box on the right side of the screen. There, under the Software version section, is your MySQL version. Easy as that!

Kiểm tra version mysql
Viewing MySQL version in phpMyAdmin

Through WordPress Dashboard

A final easy way to find your MySQL version is through your site’s WordPress admin dashboard.

To do that, visit your WordPress dashboard, and go to Tools > Site Health. Under here, first, go to the Info tab, and then to the Database section below.

Sign Up For the Newsletter

Want to know how we increased our traffic over 1000%?

Join 20,000+ others who get our weekly newsletter with insider WordPress tips!

Subscribe Now

You can find your server’s current MySQL version listed here beside the Server version label.

Kiểm tra version mysql
Finding the MySQL version in WordPress dashboard.

How to Upgrade MySQL Version

If you’ve determined your MySQL is out of date, you should rectify that as soon as possible. There are multiple ways to update MySQL to the latest versions; it all depends on what tools and operating systems you’re using.

It’s worth noting that later versions of MySQL will attempt to auto-update if the script notices that your installation is out of date. You may not need to do anything at all. If you’ve determined that MySQL is out of date and needs to be manually updated, follow these steps.

Like checking your MySQL version with the command line, you’ll need to obtain your SSH login credentials from your web host to access the terminal on your server. And, of course, you’ll need the IP address of your server.

Before updating MySQL, make sure to backup your database. For Kinsta users, it’s elementary to do in MyKinsta: log in and go to Sites > Backups. You’ll find a downloadable zip file there.

This backup contains both your database (an SQL file) and your entire site, so you’ll be extra safe if something goes wrong.

Upgrade MySQL Using cPanel

If your host offers cPanel, it’s probably the easiest way to do an upgrade since you can use the interface provided. But since cPanel defaults to MySQL 5.7 by default, you may want to do an upgrade.

As cPanel doesn’t allow you to downgrade, you should back up your database before proceeding.

Most cPanel installations come with Web Host Manager, WHM, which gives you deeper root access.

Step 1: Log in to WHM by visiting either “example-site.com:2087” or “example-site.com/whm.” You can also ask your web host how to access WHM.

Step 2: Navigate to Software > MySQL Upgrade or type “MySQL” into the search bar. You may also find it under SQL Services > MySQL/MariaDB Upgrade.

Step 3: Select the version of MySQL you want to upgrade to and click Next. Now follow the upgrade steps, and it’ll take care of everything for you.

Kiểm tra version mysql
Web Host Manager cPanel MySQL update

This method is by far the simplest way to do a MySQL upgrade, but if your host doesn’t offer cPanel or WHM, you may need to do it manually.

Upgrade MySQL in Linux/Ubuntu

There are a variety of Linux distributions, but Ubuntu is by far the most common. These instructions should work for any operating system that uses the apt/apt-get function to install the software.

Need a hosting solution that gives you a competitive edge? Kinsta’s got you covered with incredible speed, state-of-the-art security, and auto-scaling. Check out our plans

Kiểm tra version mysql
MySQL APT Repository

Linux can easily SSH connect without any additional software requirements. So, you can get right into your server.

Step 1: Launch the Terminal. Obtain your SSH credentials and use the ssh command to log in.

Step 2: You should have the MySQL apt Repository installed since MySQL is already on your server. Update your package list with the following command:

sudo apt-get update

Step 3: Now upgrade MySQL.

sudo apt-get upgrade mysql-server

You can also try this command if the above doesn’t work:

sudo apt-get install mysql-server

It’ll prompt you to choose a version; select 5.7 or 8.0. If you’re upgrading from 5.6, you should update to 5.7 first, rather than going straight to 8.0.

Upgrade MySQL on macOS

While macOS comes with its own version of MySQL, you can’t upgrade it through the usual methods. And most likely, your server is using a separate instance.

Many of these steps are very similar to updating MySQL on Linux. macOS similarly has SSH built into the operating system, so all you need to do is run the commands.

We’ll assume you’re using Homebrew as a package manager as it’s the simplest way to install and update MySQL on Mac. You shouldn’t attempt to upgrade MySQL with Homebrew if you didn’t use it to install it initially.

Kiểm tra version mysql
Using Homebrew to install MySQL on Mac

Step 1: Launch the Terminal program and log in with the ssh command.

Step 2: Run these commands using Homebrew.

brew update
brew install mysql

This command should automatically install 8.0 and upgrade any existing versions.

Are you running into trouble? Try uninstalling the current version of MySQL first. Use these commands:

brew remove mysql
brew cleanup

Then you can again attempt to run the update and install commands again.

Step 3: Make sure you start the MySQL server again manually:

mysql.server start

Upgrade MySQL in Windows

Unlike Mac and Linux, Windows can’t use SSH by default. Instead, you’ll need to install a separate client, and then you can connect to your server.

Step 1: Download PuTTY and install it on your system. Launch it and input your SSH credentials to connect to the server. 3306 is the default port number. Ignore any security alerts; these are normal.

Step 2: Assuming you’re connecting to a Linux terminal, you can use the Linux commands in the Linux/Ubuntu section above to perform the upgrade.

You can also use the MySQL installer to download MySQL onto the system directly. This process skips the SSH connection entirely.

Keeping your MySQL version up to date is crucial for site security 🔒 See how to upgrade your version here ⬇️Click to Tweet

Summary

With any software, it’s crucial to keep it up to date. And with MySQL being so integral to your website and its database, it’s even more imperative. Unfortunately, too many web admins choose to let their MySQL version fall behind, to the detriment of their website’s speed and security.

Luckily, checking your MySQL version and upgrading it is almost always a smooth process. While you should definitely back up your website and database for emergencies, you aren’t likely to experience any issues.

With just a tiny command in your web server’s terminal, your database will be well optimized and faster than ever.


Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:

  • Easy setup and management in the MyKinsta dashboard
  • 24/7 expert support
  • The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
  • An enterprise-level Cloudflare integration for speed and security
  • Global audience reach with up to 35 data centers and 275+ PoPs worldwide

Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.