分页: 1 / 1

请教安装DBD::mysql碰到的问题

发表于 : 2018-11-18 18:34
shawrain
各位大侠,请教个问题:
运行软件时报错:Can't locate DBD/mysql.pm in @INC (you may need to install the DBD::mysql module)

进入CPAN安装时也报错了:
cpan[1]> install DBD::mysql
Reading '/root/.cpan/Metadata'
Database was generated on Sun, 18 Nov 2018 06:17:03 GMT
Running install for module 'DBD::mysql'
Checksum for /root/.cpan/sources/authors/id/D/DV/DVEEDEN/DBD-mysql-4.049.tar.gz ok
Scanning cache /root/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring D/DV/DVEEDEN/DBD-mysql-4.049.tar.gz with Makefile.PL
Can't exec "mysql_config": 没有那个文件或目录 at Makefile.PL line 89.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!


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": 没有那个文件或目录 at Makefile.PL line 603.
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<dir>

to set this directory. For details see DBD::mysql::INSTALL,
section "C Compiler flags" or type

perl Makefile.PL --help
Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
DVEEDEN/DBD-mysql-4.049.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Failed during this command:
DVEEDEN/DBD-mysql-4.049.tar.gz : writemakefile NO '/usr/bin/perl Makefile.PL INSTALLDIRS=site' returned status 512



是什么原因?怎么解决? :What

Re: 请教安装DBD::mysql碰到的问题

发表于 : 2018-11-18 21:03
astolia
你要装DBD::mysql,cpan要去下载它的源代码进行编译,但你系统上没有安装mysql的相关开发文件,导致mysql_config找不到没法编译

代码: 全选

sudo apt install libmysqlclient-dev

Re: 请教安装DBD::mysql碰到的问题

发表于 : 2018-11-19 20:50
shawrain
astolia 写了: 2018-11-18 21:03 你要装DBD::mysql,cpan要去下载它的源代码进行编译,但你系统上没有安装mysql的相关开发文件,导致mysql_config找不到没法编译

代码: 全选

sudo apt install libmysqlclient-dev
成功解决了,谢谢