1. Home
  2. Linux
  3. Can’t exec mysql_config: No such file or directory at Makefile.PL [Fix]

Can’t exec mysql_config: No such file or directory at Makefile.PL [Fix]

If you are getting an error “Can’t exec mysql_config: No such file or directory at Makefile.PL”, then here’s how you can solve the error. Before that, have a look at the complete error message:

Can't exec "mysql_config": No such file or directory at Makefile.PL line 561.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located. Failed to determine directory of mysql.h

How to fix Can’t exec mysql_config: No such file or directory at Makefile.PL

This error occurs if the system cannot find MySQL client package. The install script "Makefile.PL" can be configured using lots of switches such as --cflags, --libs etc…

cflags is a list of flags that are given to C compiler. The important flag is the location of the MySQL header files. To determine the default flags, mysql_config script can be used as shown below.

# mysql_config --cflags
 -I/usr/include/mysql

Similarly, --libs is a list of flags that are given to the linker or loader. Here, the default flags are determined by executing mysql_config command as shown below:

# mysql_config --libs
 -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl

So, generally if --cflags and --libs are not specified in the command line, then mysql_config script will be used and this script comes as part of the MySQL client distribution.  Well, here’s a reference that explains this in detail.

But in most cases, if you had installed only MySQL server using 'apt-get install mysql-server' then there are chances that you don’t have MySQL client library installed. It means, the system is missing mysql_config command as well.

To fix this issue, install MySQL client library as shown below:

$ sudo apt-get install libmysqlclient-dev

Check if mysql_config is installed using the below command:

$ which mysql_config
/usr/bin/mysql_config
# whereis mysql_config
mysql_config: /usr/bin/mysql_config /usr/share/man/man1/mysql_config.1.gz

That’s it! Now try executing the install script “Makefile.PL” and it should located mysql_config without any issue.

Updated on January 25, 2018

Was this article helpful?

Related Articles

Leave a Comment