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

I'm putting together a script that has a requirement of knowing[15|16|18] .so file. It's usually located in /usr/lib/ , /usr/lib64/ or a mysql/ subdirectory of the aforementioned directories.

I have tried a few things. First of all, sometimes the location can be found in a mysql file in /etc/* , but that has not been the case on many servers.

Another possibility is searching the above directories for those files. I will know which version of MySQL is being used, so I can search for the proper .so file, but unfortunately many people seem to have multiple .so's installed. For example both may exist:

  • /usr/lib/

  • /usr/lib64/

In this situation, I'm not sure which .so file is being used.

Is there anyway to tell where the proper is installed?

share|improve this question
Can you be more specific about what you're trying to accomplish? – Andrew Case Nov 1 '11 at 5:44
up vote 4 down vote accepted

This will give you all of the libmysql files recognized by the linker. The higher on the list has the higher priority and is more likely to be linked against.

/sbin/ldconfig -p | grep mysql | cut -d\> -f2

One caveat though is that since most applications link by doing a gcc -lmysqlclient they will favor a file in the ldconfig listed as rather than .so.15 or whatever. So personally I would assume that the first is the correct one.

share|improve this answer

Which shared object library is used depends on the user enviroment and binary that is run. If you su - USER to the user that is running the binary and then run the command ldd MYSQLBINARY | grep mysqlclient that will determine which mysqlclient library is going to be used.

By default on most Linux systems, /usr/lib (used for x86 binaries) and /usr/lib64 (used for x86_64 bit binaries).

Btw, running locate to get a list of all the shared objects that are installed system wide (probably won't report .so files installed in user paths though).

share|improve this answer

Remember that the so being used might not even be in /usr/lib or /usr/lib64.....sometimes these things reside in or under /usr/local/lib as well depending on how things were compiled.

I'm sure that there is a totally foolproof method of making the determination. One can make some darn good guesses however.

share|improve this answer

If you know the package name why not list the content of the package and grep for it?

In Redhat, something like ...

rpm -ql mysql | grep libmysql
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.