MySQL is one of the most popular open-source database management systems and is used by many websites and organizations. There are a lot of MySQL versions available on the Internet. If you want to host an application that requires a specific MySQL version, you will need to know the version of MySQL installed on your server. Show
In this post, we will show you how to check the MySQL version in Linux. Prerequisites
1. Check the MySQL Version via Command LineThe simple and easiest way to check the MySQL version on your system is from the command line. If you have root access to your Linux server, you can use the following command to check the MySQL version: mysql -V You will get the MySQL version in the following output: mysql Ver 8.0.26 for Linux on x86_64 (Source distribution) MySQL also provides a MySQLAdmin command-line utility to perform several administrative tasks. You can also use this utility to check the MySQL version: mysqladmin -V You will get the following output: mysqladmin Ver 8.0.26 for Linux on x86_64 (Source distribution) Also ReadHow to Check and Repair MySQL 2. Check MySQL Version Using SHOW VARIABLESYou can also use the MySQL command-line utility to check the MySQL version. First, connect to the MySQL server with the following command: mysql -u root -p Once you are connected, use the following command to check the MySQL version: mysql> SHOW VARIABLES LIKE '%version%'; You will get the MySQL version in the following output: +--------------------------+-------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------+ | admin_tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 | | immediate_server_version | 999999 | | innodb_version | 8.0.26 | | original_server_version | 999999 | | protocol_version | 10 | | replica_type_conversions | | | slave_type_conversions | | | tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 | | version | 8.0.26 | | version_comment | Source distribution | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | +--------------------------+-------------------------------+ Also ReadHow to Create and Delete User in MySQL 3. Check MySQL Version Using SELECT VERSIONAfter connecting to the MySQL server, you can also use the SELECT VERSION command to check the MySQL version. mysql> SELECT VERSION(); You will get the following output: +-----------+ | VERSION() | +-----------+ | 8.0.26 | +-----------+ 1 row in set (0.00 sec) 4. Check MySQL Version Using STATUSYou can also run the STATUS query inside the MySQL shell to check the MySQL version: mysql> STATUS; You will get the following output: mysql Ver 8.0.26 for Linux on x86_64 (Source distribution)0 5. Check MySQL Version Using PHPIf your application is hosted on the shared hosting and doesn’t have access to the command line, you can upload the PHP file to your website directory and check the MySQL version. To check the MySQL version using PHP, create a file named info.php with the following content and upload it to your website directory: mysql Ver 8.0.26 for Linux on x86_64 (Source distribution)1 Next, open your web browser and access info.php file using the URL http://your-website-name/info.php. This will display the MySQL version on your web browser screen. ConclusionIn this post, we explained several methods to find out the MySQL version in your Linux system. You can now choose your preferred method to check the MySQL version. Try MySQL on VPS hosting from Atlantic.Net! When MySQL client is installed, the “mysql” command is added. The same thing goes for the server installation, with the “mysqld” command. Testing these commands can tell if MySQL is installed on the Linux server or not. Here are the commands you can try safely: Another method is to use “dpkg” to list all the packages installed on the system, and specifically search for anything with “mysql” in the package name. For example: In this screenshot, you can see that the MySQL client is installed (it’s returning something with –version). The “dpkg -l” command is also telling me exactly which packages are installed (mysql-common, libmysqlclient and libdbd-mysql-perl). If MySQL is not installed, you’ll get an error “Command ‘mysql’ not found”, like on this example: Get My Cheat Sheet! And the “dpkg” command will return nothing: Using one of these commands should give you the answer you were looking for. Don’t forget that you may have the MySQL client installed, but not the server. That’s why there are two commands: If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy. How to know if MySQL is running?The MySQL server is a service, which means it can be installed but not running. On Linux, you can use this command to check if it’s started: On my Ubuntu virtual machine, it looks like this: With colors, it’s pretty straightforward. I have a green mention “active (running)” on the third line, so my server is up and running. Most of the time, it will be “active” or “inactive”. If MySQL is not running, you can start it with: Then use the status command again to make sure it started correctly. If it doesn’t work, you may have an error in the status command output, or you can check the log files to find what’s going on. How to check which MySQL version is running?On Linux, the command “mysql –version” gives the version number of the MySQL client, while “mysqld –version” shows the version of the MySQL server (if installed). While writing this article, I was using MariaDB 10.6.7, so I got something like this: Even if MariaDB is now the most popular MySQL server package on Linux (and the default solution on most distributions I think), your server is not necessarily using it yet, so it will also answer this question. Get My Cheat Sheet! With these commands, I get the full description of the MySQL packages I’m using. In this case, I have MariaDB server and client installed, it’s version 10.6.7 in 64 bits, built for Ubuntu 22.04. How to know which port MySQL is using?By default, MySQL server is using port 3306. It can be changed in the configuration file, and a network scan or the “netstat” command can tell which port is currently used. If you have access to the MySQL server, the easiest way is to use this query to get the information: It will output a table with the port number. Display the MySQL configuration file with: In this example, the port configuration line is still commented on, so it’s the default value (3306). Another way is to use netstat, to see which services are running, and on which ports they are listening: If your MySQL server is not using the default port, you need to specify it in the MySQL client command. Something like: Where is MySQL located on Linux?By default, MySQL data is stored under /var/lib/mysql on Linux, while the configuration files are under /etc/mysql. Once again, you can use dpkg to list all the files associated with the MySQL server package: This will give you something like: Where you can see exactly which files are being used by this package. As a reminder, you can use: Get My Cheat Sheet! Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums. You may also like:
How to install MySQL?MySQL is available in the default repository on most distributions, but is most likely named “MariaDB”. It can be installed with “sudo apt install mariadb-server” for the server part, or “sudo apt install mariadb-client” for the client only. How can I know MySQL is installed or not?Check MySQL Version with V Command. The easiest way to find the MySQL version is with the command: mysql -V. ... . How to Find Version Number with mysql Command. The MySQL command-line client is a simple SQL shell with input editing capabilities. ... . SHOW VARIABLES LIKE Statement. ... . SELECT VERSION Statement. ... . STATUS Command.. How do I know if MySQL is running on Windows?1 Answer. Got to Start, search for "Services". Open the application.. Search MySQL (if 8 then its mysql80), right click and start.. How to check version of MySQL?In MySQL Command Line Client, enter the following command: SHOW VARIABLES LIKE 'version'; The MySQL version will be shown instantly.
Where is my MySQL installed?By default, the option file is located at %PROGRAMDATA%\MySQL\MySQL Server <version no>\my. ini .
|