12

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

Elitmiar
  • 775
  • 3
  • 15
  • 31
  • If you need to downvote this question, please tell me why? – Elitmiar 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: http://catb.org/~esr/faqs/smart-questions.html – pboin Sep 30 '09 at 14:37

6 Answers6

13

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

mysql

or

mysql --version

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

Dave Drager
  • 8,375
  • 29
  • 45
2

What version of linux?

Debian dpkg -l 'mysql*'

Ryaner
  • 3,097
  • 5
  • 25
  • 33
1

How about rpm -q mysql (Fedora/RedHat)

Satanicpuppy
  • 5,946
  • 1
  • 17
  • 18
1

Other than the good suggestions above, try:

locate mysqld_safe

or

ls /etc/init.d | grep mysql

If you think it might be running already try:

ps waxu | grep mysql

or

netstat -pan | grep mysql
Twirrim
  • 673
  • 4
  • 8
0

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
        libmysqlclient_r.so.15 (libc6) => /usr/lib/libmysqlclient_r.so.15
        libmysqlclient_r.so.14 (libc6) => /usr/lib/libmysqlclient_r.so.14
        libmysqlclient_r.so.12 (libc6) => /usr/lib/libmysqlclient_r.so.12
        libmysqlclient_r.so.10 (libc6) => /usr/lib/libmysqlclient_r.so.10
        libmysqlclient_r.so (libc6) => /usr/lib/libmysqlclient_r.so
        libmysqlclient.so.15 (libc6) => /usr/lib/libmysqlclient.so.15
        libmysqlclient.so.14 (libc6) => /usr/lib/libmysqlclient.so.14
        libmysqlclient.so.12 (libc6) => /usr/lib/libmysqlclient.so.12
        libmysqlclient.so.10 (libc6) => /usr/lib/libmysqlclient.so.10
        libmysqlclient.so (libc6) => /usr/lib/libmysqlclient.so

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
/usr/bin/mysqld_safe
root@tower:~ # which mysql
/usr/bin/mysql
root@tower:~ #

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

root@tower:~ # which which
/usr/bin/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.

Tim Post
  • 1,525
  • 13
  • 25
-1

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

find / -name mysql
Michael Pobega
  • 934
  • 5
  • 12