I need to check if mysql is installed on a ubuntu server. Is there a way to determine if mySql has been installed ? Thanks.
8 Answers
You can use tool dpkg for managing packages in Debian operating system.
Example
dpkg --get-selections | grep mysql
if it's listed as installed, you got it. Else you need to get it.
-
can you tell me that location where it get installed in ubuntu ? Commented Dec 10, 2015 at 23:29
-
1
-
1Not sure this is working in the latest Kubuntu 17.1?. In this screenshot it shows it's not installed (shows 'install', not 'installed'). As a test I tried to install the PHP extension, and it shows it's already installed: i.imgur.com/RsczcPc.png Commented May 3, 2018 at 23:30
-
This answer is plain wrong - perhaps you only have
mysql-client
installed? Or justmysql-common
? Or perhaps evenlibqt5sql5-mysql
orlua-dbi-mysql-dev
? Commented Jun 25, 2019 at 10:51
"mysql" may be found even if mysql and mariadb is uninstalled, but not "mysqld".
Faster than rpm -qa | grep mysqld is:
which mysqld
Multiple ways of searching for the program.
Type mysql
in your terminal, see the result.
Search the /usr/bin
, /bin
directories for the binary.
Type apt-cache show mysql
to see if it is installed
locate mysql
-
The apt-cache cmd doesn't seem to work (or at least not on the latest Kubuntu 17.1): i.imgur.com/NFOyPUl.png Commented May 3, 2018 at 23:24
-
-
Actually, I think it doesn't work, either -- it shows some cached information, but not what is installed– JohnP2Commented Jan 22, 2022 at 18:48
Lots of answers. It should have been a simple command. Just type mysql --version
on your terminal and hit enter.
In an RPM-based Linux, you can check presence of MySQL like this:
rpm -qa | grep mysql
For debian or other dpkg-based systems, check like this:
dpkg -l mysql-server libmysqlclient*dev*
-
While this may solve the OP's problem, a few words of explanation would make this answer even better for the current and future readers of this problem.– ThomCommented May 6, 2015 at 11:40
# mysqladmin -u root -p status
Output:
Enter password:
Uptime: 4 Threads: 1 Questions: 62 Slow queries: 0 Opens: 51 Flush tables: 1 Open tables: 45 Queries per second avg: 15.500
It means MySQL serer is running
If server is not running then it will dump error as follows
# mysqladmin -u root -p status
Output :
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
So Under Debian Linux you can type following command
# /etc/init.d/mysql status
Try executing mysql
or mysql -- version
on terminal.
It will prompt version otherwise Command Not Found