5

Where can I find the include files for MySQL on Linux? I looked in /usr/include/mysql according to this but they are not there. My apache web server works fine with MySQL 5.1 up and running with PHP 5, but I can't find where the includes directory is!!

Thanks for your help!

Ophidian
  • 2,178
  • 14
  • 14

3 Answers3

8
$ mysql_config --include

On my system, this prints -I/usr/include/mysql

If the directory revealed by mysql_config doesn't have the right include files, your installation may have been partial or may have been altered after the fact.

From the documentation:

mysql_config provides you with useful information for compiling your MySQL client and connecting it to MySQL....

--include

Compiler options to find MySQL include files.

pilcrow
  • 459
  • 5
  • 19
  • not work for me, there is no mysql_config binary with mysql 5.5.35. :( – Jean-Luc Barat Sep 24 '16 at 18:02
  • @Jean-Luc Barat, perhaps you are missing the "devel" files. Others on even older 5.5 versions [don't have that problem](http://stackoverflow.com/a/10521787/132382). – pilcrow Sep 24 '16 at 21:22
3

This really depends on the Linux distro you are using. Most binary distros ship the headers separate from the application itself, often in a -devel package.

For instance, on my Fedora 12 machine the mysql-devel package has the following description:

MySQL is a multi-user, multi-threaded SQL database server. This package contains the libraries and header files that are needed for developing MySQL client applications.

On Fedora, CentOS, or RHEL,you can install this package by yum install mysql-devel as root. Debian and Ubuntu systems will have a similar package name and command for apt.

Ophidian
  • 2,178
  • 14
  • 14
1

It worked for me by installing libmysqlclient-dev in ubuntu-14.04.

Then I could find files in /usr/include/mysql

xyz
  • 11
  • 1