In Linux systems, installing a MySQL database is a common operation, and checking the installed MySQL version information is also an essential task.
This article will introduce you to the related operations on how to view the installed MySQL version information in the Linux system.
To view the MySQL version information through the command line, you need to enter the following command in the terminal:
mysql --version
Execute the command After that, the MySQL version information will be returned, for example:
mysql Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using EditLine wrapper
where the 5.7.30 version number is the current MySQL version number. In addition, you can also use the following command to view the installation location of MySQL:
which mysql
After executing the command, the installation location of MySQL will be displayed. For example:
/usr/bin/mysql
In Linux systems, the file names of MySQL services usually start with "mysql" or "mysqld" , so you can get the MySQL version information by checking the system services.
You can view all service information in the current system through the following command:
systemctl list-units --type=service
After executing the command, all service information of type "service" will be displayed, including MySQL service information. If the MySQL service has been started, you can view the detailed information of the MySQL service through the following command:
systemctl status mysql.service
After executing the command, the detailed information of the MySQL service will be returned, including the version information of MySQL. For example:
mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: Active: active (running) since Tue 2020-07-28 15:12:02 CST; 1 weeks 0 days a Main PID: 8199 (mysqld) Tasks: 28 Memory: 202.2M CPU: 1.296s CGroup: /system.slice/mysql.service └─8199 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pi ... Version: '5.7.30-0ubuntu0.18.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
The "Version" field displays the MySQL version information.
MySQL client is a command line tool used to manage MySQL databases by connecting to the MySQL database and executing related commands , you can view the version information of MySQL.
You can start the MySQL client through the following command:
mysql -u root -p
After executing the command, you need to enter the password of the MySQL user "root" and then connect to the MySQL database. In the MySQL client, you can execute the following command to view the version information of MySQL:
SELECT VERSION();
After executing the command, the version information of MySQL will be returned. For example:
+-------------------------+ | VERSION() | +-------------------------+ | 5.7.30-0ubuntu0.18.04.1 | +-------------------------+
So, the above are three methods to view the installed MySQL version information in Linux system, they are all very simple and easy to use. If you need to manage and configure a MySQL database on the server, these methods will help you work better.
The above is the detailed content of linux view installed mysql. For more information, please follow other related articles on the PHP Chinese website!