Navigation Advertising

Next post Previous post

Post content

MySQL in a custom dir on Linux

Linux MySQL

If you have installed MySQL server in the standard directory /usr/local/mysql, do not read this post. Else, you may want to know

how to use MySQL shared libraries on your Linux system

For organization purposes, I have installed MySQL in /home dir (which is a separate partition), precisely in /home/server/mysql. Thus, I keep mysql/var, directory (which contains databases) safe from heavy system changes.

My system did not recognized the shared library libmysqlclient, that is under /home/server/mysql/lib/mysql.
How do you tell Linux “Hey, you will find the library here, go and use it”?

Just edit the file /etc/ld.so.conf and add the path to your library. Then, reboot or give this command:

ldconfig -v

to register new libraries.


Compiling programs that require MySQL components

Another issue you’ll have to deal with when your MySQL is installed in a non-standard path, is the source compilation and use of programs that require some MySQL components.

For example, I use a C program that has this header on its source:

#include <mysql/mysql.h>

I got errors related to paths when compiling this source.
The solution is not changing the source in order to make #include lines match real paths, but consists in telling the compiler where mysql directory is. Compile with such a command line (or change your Makefile accordingly):

gcc -I/home/server/mysql/include/ -L/home/server/mysql/lib/mysql yourprogram.c -lmysqlclient
Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • digg
  • del.icio.us
  • blogmarks
  • co.mments
  • NewsVine
  • Furl

Related articles

Other posts filed under Linux, MySQL

Comments and trackbacks

Add your comment:

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>