The Quick Answer
mysql --version
mysql -V is the short form. The line shows the version of the mysql client program, the platform, and the distribution that built it. It does not open a connection, so it works without a password.
The client and the server are separate programs. On a server where both come from the same package they match, but the client can also talk to a server on another machine, or to a newer server after a partial upgrade. When the server version matters, ask the server.
Ask the Server
Log in as an administrative user, with sudo mysql where the distribution uses socket login for root, or mysql -u root -p and the password at the prompt. Then:
SELECT VERSION();
Any account can run this query, including an application account. Two more ways from inside the client:
SHOW VARIABLES LIKE 'version%';
status
SHOW VARIABLES adds the build comment and the platform. status (or \s) prints the client version, the server version, the connection, and the uptime together.
From the shell in one line:
sudo mysql -e "SELECT VERSION();"
The Server Program Without Logging In
/usr/sbin/mysqld --version
This asks the installed server binary directly. It sits in /usr/sbin, which is not always in a normal user's path; if mysqld is not found, give the full path as above, or see command not found in Linux. On MariaDB, the server program is called mariadbd, and mysqld may be a link to it.
The binary on disk can be newer than the running server if the package was upgraded and the service was not restarted. SELECT VERSION(); always shows the running one.
The Package Version
On Ubuntu and Debian (Debian 12 and 13 have no mysql-server package, so ask for mariadb-server there):
apt policy mysql-server
apt policy mariadb-server
dpkg -l | grep -i -E 'mysql|mariadb'
On AlmaLinux and Rocky Linux:
rpm -qa | grep -i -E 'mysql|mariadb'
apt policy also shows which version the repositories offer, so you can see whether an update is waiting. To bring packages up to date, see sudo apt update.
MySQL or MariaDB?
MariaDB installs a client that answers to mysql and a server that speaks the same protocol, so many tools cannot tell them apart. The version string can:
- MySQL: the version is a plain number such as 8.4.11 or 9.7.4, sometimes with a distribution suffix, and the client line starts with
mysqlandVer. - MariaDB: the version contains the word
MariaDB, as in a string ending in-MariaDB, and recent clients name themselvesmariadb.
On Debian, the default database server package, default-mysql-server, installs MariaDB. On Ubuntu, mysql-server installs MySQL: 8.0 on Ubuntu 24.04 and 8.4 on Ubuntu 26.04. On AlmaLinux and Rocky Linux both are available, and the package name tells you which one you have.
Reading the Number
| Part | Meaning |
|---|---|
| Major | Large changes, read release notes |
| Minor | The release series |
| Patch | Fixes within the series |
Since 9.7.4, MySQL versions can carry a fourth number for updates of a release, as in 9.7.4.1. MySQL publishes long-term support (LTS) series, currently 8.4 and 9.7, alongside innovation releases that are supported only until the next one. For a server, stay on an LTS series and install its patch releases. Upgrades between series change defaults; back up all databases first.
Check the OS Too
Which MySQL version a package provides depends on the release of the operating system. If you report a problem or follow a guide, give both numbers. See how to check your Ubuntu version for the second one.