What command returns the current version of a MySQL database?
For UBUNTU you can try the following command to check mysql version :
mysql --version
Many answers suggest to use mysql --version
. But the mysql
programm is the client. The server is mysqld
. So the command should be
mysqld --version
or
mysqld --help
That works for me on Debian and Windows.
When connected to a MySQL server with a client you can use
select version()
or
select @@version
mysqladmin version
OR mysqladmin -V
With CLI in one line :
mysql --user=root --password=pass --host=localhost db_name --execute='select version()';
or
mysql -uroot -ppass -hlocalhost db_name -e 'select version()';
return something like this :
+-----------+
| version() |
+-----------+
| 5.6.34 |
+-----------+
For Mac,
login to mysql server.
execute the following command:
SHOW VARIABLES LIKE "%version%";
Here two more methods:
Linux: Mysql view version: from PHP
From a PHP function, we can see the version used:
mysql_get_server_info ([resource $ link_identifier = NULL]): string
Linux: Mysql view version: Package version
For RedHat / CentOS operating systems:
rpm -qa | grep mysql
For Debian / Ubuntu operating systems:
rpm -qa | grep mysql
Extracted from: https://www.sysadmit.com/2019/03/linux-mysql-ver-version.html