试图安装Perl-Mysql DBD,无法找到mysql_config

时间:2011-01-18 22:22:31

标签: mysql database perl

这是输出:

Ian-MacBook-Pro:DBD-mysql-4.011 ianseyer$ sudo Perl Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem 
not contain the path to mysql_config. Resorting to guessed values!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the 
database user 'root' can connect to your MySQL server 
and has the proper privileges that these tests require such 
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others. 

mysql> grant all privileges on test.* to 'root'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.pl --testuser=username

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

  perl Makefile.PL --cflags=-I

to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type

  perl Makefile.PL --help

我已经研究过这个问题并尝试使用符号链接无效。

我必须自己编译吗?

9 个答案:

答案 0 :(得分:37)

如果您安装了每个人都安装的mysql服务器: sudo apt-get install mysql-server(或类似的东西)

你缺少一些额外的文件,这个perl模块的makefile依赖于这些文件。

您可以尝试通过安装以下软件包来解决此问题:

sudo apt-get install libmysqlclient-dev 

REFERECE: http://cpansearch.perl.org/src/RUDY/DBD-mysql-2.9008/INSTALL.html#configuration

答案 1 :(得分:15)

应用于ubuntu / debian用户(我正在运行U-12.0.4),上面建议用户这样做:

sudo apt-get install libmysqlclient-dev

但是安装的maketest部分存在另一个问题,其中“密码:否”失败。要绕过该测试,只需使用force:

sudo cpan -f DBD::mysql

答案 2 :(得分:8)

如果你使用ubuntu,你可以使用下面的cmd

轻松安装
    sudo apt-get install libdbd-mysql-perl

有关详细信息,请查看cpan install.pod包含有关其他Linux风格的详细信息

答案 3 :(得分:6)

安装与发行版和mysql服务器版本相关的mysql-devel包。

答案 4 :(得分:4)

你只需要在本地安装mysql-server和mysql-devel,这样cpan就可以构建模块,之后你可以删除mysql服务器。

答案 5 :(得分:3)

在MySQL目录下找到脚本mysql_config.pl,并运行Makefile.PL,如:

perl Makefile.PL --mysql_config=/path/to/mysql-5.x.y.zzz/bin/mysql_config.pl

答案 6 :(得分:2)

如果您尝试通过CPAN安装,据我所知,您不能直接设置--mysql_config选项。并且,包括PATH环境变量中包含mysql_config的目录似乎没有帮助。

但是,如果您确实在某处可以使用mysql_config文件,则可以执行以下操作以使安装成功:

ln -s /path/to/mysql_config /usr/local/bin/

然后,删除DBD :: mysql安装后的符号链接。

安装期间的测试仍然会失败,除非您在系统的某个中央/默认位置安装了MySQL,但安装仍然会成功。

如果您没有mysql_config,可以从mysql.com的MySQL社区服务器的tar.gz下载中获取。它将位于解压缩文件的bin /子目录中。如果您想在系统上安装MySQL,可以选择下载RPM并安装它们,或者通过操作系统的软件包管理系统进行安装。

答案 7 :(得分:0)

我得到了测试错误。这帮助了我;

perl Makefile.PL  --testuser=bob  --testpass=bobtest

答案 8 :(得分:0)

为CentOS 7尝试yum install mariadb-devel,然后 运行所需的Perl模块安装,例如cpan DBD::mysql