Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to determine if mySql has been installed on a Linux server?

share|improve this question
If you need to downvote this question, please tell me why? – Roland Sep 30 '09 at 14:28
Probably because you didn't ask your question well. Here's the de facto way to do it right: – pboin Sep 30 '09 at 14:37
up vote 5 down vote accepted

Assuming that you are looking for a mysql binary installed with a typical package, run the command:



mysql --version

If it comes back with a response, it is installed, if it says "command not found" then it is not installed.

share|improve this answer
Assuming that it's in the path or current directory. – squillman Sep 30 '09 at 14:56
Also assuming it wasn't compiled to use a different name! :) – Dave Drager Sep 30 '09 at 16:00

What version of linux?

Debian dpkg -l 'mysql*'

share|improve this answer

How about rpm -q mysql (Fedora/RedHat)

share|improve this answer
rpm -qa | grep mysql is probably safer since the main package is mysql-server – Ophidian Oct 1 '09 at 3:36

Other than the good suggestions above, try:

locate mysqld_safe


ls /etc/init.d | grep mysql

If you think it might be running already try:

ps waxu | grep mysql


netstat -pan | grep mysql
share|improve this answer

On every distribution that I know of, MySQL installs some shared libraries for its client, named appropriately limbysqlclient. You can check for this by using the ldconfig tool, which will query to see if the object is installed:

ldconfig -p | grep mysqlclient (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/ (libc6) => /usr/lib/

This tells you that there's a very good chance that MySQL is installed. Its very rare that someone would install the shared objects only, without installing at least the client. Now, check for the existence of the actual client and server:

root@tower:~ # which mysqld_safe
root@tower:~ # which mysql
root@tower:~ #

The `which' program may not be installed, so check for it via:

root@tower:~ # which which

Hope this helps. Short of querying the package manager (kind of hard to do in a script if you have many systems running different distributions) it seems a very reliable way to tell.

share|improve this answer

The easiest and most distro-agnostic way of answering your question is;

find / -name mysql
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.