How to Check MySQL & MariaDB Versions in Ubuntu

This tutorial guides users on how to check MySQL or MariaDB server versions in Ubuntu Linux using various methods. These include using the built-in `mysqld –version` or `mysqladmin -V` commands, logging into the server using the `sudo mysql` command, or running the `STATUS` query. Other methods include using PHP to create a file displaying the…

This brief tutorial shows students and new users how to check MySQL | MariaDB server versions in Ubuntu Linux.

How do you know which MySQL or MariaDB database server versions you’re running? How do you find out? What command do you use?

The answer to all your questions is detailed below.

Nowadays, MariaDB database servers are used with many open-source projects everywhere. This was not the case a few years ago.

Then, MySQL was probably the only database server used in most open-source projects. However, Oracle’s new parent company’s licensing changes established an alternative to MySQL called MariaDB.

To get started with checking MySQL or MariaDB database versions, follow the steps below:

Check the MySQL Server version

MySQL and MariaDB have a built-in tool to check the server versions. Simply run the commands below with the -d argument to display the server’s current version.

mysqld --version

Running the command above will show which version the server is running.

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

MariaDB output:
mysqld  Ver 10.3.25-MariaDB-0ubuntu0.20.04.1 for debian-linux-gnu on x86_64 (Ubuntu 20.04)

If you run the commands below, it should also display the server version

mysqladmin -V

Output from the command above.

MySQL output:
mysqladmin  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

MariaDB output:
mysqladmin  Ver 9.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu on x86_64

MySQL and MariaDB come with a client tool that also should help you find the server version. From the command line, invoke the client tool by running the command below:

sudo mysql

That will allow you to log in and display the server details, including the version number.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2021, 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> 

MariaDB server will output the message below:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 49
Server version: 10.3.25-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

Or run the STATUS query to display the server details, including the version number.

mysql> STATUS;

That should display the output below:

Connection id:        9
 Current database:    
 Current user:        root@localhost
 SSL:            Not in use
 Current pager:        stdout
 Using outfile:        ''
 Using delimiter:    ;
 Server version:        8.0.23-0ubuntu0.20.04.1 (Ubuntu)
 Protocol version:    10
 Connection:        Localhost via UNIX socket
 Server characterset:    utf8mb4
 Db     characterset:    utf8mb4
 Client characterset:    utf8mb4
 Conn.  characterset:    utf8mb4
 UNIX socket:        /var/run/mysqld/mysqld.sock
 Binary data as:        Hexadecimal
 Uptime:            6 min 54 sec
 Threads: 2  Questions: 5  Slow queries: 0  Opens: 117  Flush tables: 3  Open tables: 36  Queries per second avg: 0.012

These methods are a few that help you determine the server version of MySQL or MariaDB from the command line console.

Using phpMyAdmin

If you have phpMyAdmin installed, you should also be able to see the server version from the portal. Login and view the server detail from the dashboard.

Using PHP

If you can upload a file to your web root directory, simply create a local file called mysqlversion.php. Then copy and paste the code below into the file and upload it to your server root folder.

<?php

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

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

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

Then browse to the server hostname or IP address followed by mysqlversion.php

http://localhost/mysqlversion.php

That will display your server version.

There might be other ways to view your database server version number in Ubuntu Linux. However, the few methods above should get you started.

Conclusion:

This post showed you how to find the version number of MySQL or MariaDB database server in Ubuntu Linux. If you find any error above, please use the comment form below to report.

Comments

  1. […] How to find what version of MySQL or MariaDB runs on Ubuntu Linux […]

  2. […] How to find what version of MySQL or MariaDB runs on Ubuntu Linux […]

  3. […] How to find what version of MySQL or MariaDB runs on Ubuntu Linux […]

Leave a Reply

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