DBD-mysql
DBD-mysql copied to clipboard
cpan installation DBD::mysql problem on macos + problem resolution [rt.cpan.org #90303]
Migrated from rt.cpan.org#90303 (status was 'new')
Requestors:
From [email protected] on 2013-11-12 15:49:46:
Hello.
When I install DBD::mysql I get such problem:
# Failed test 'use DBD::mysql;'
# at t/00base.t line 18.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/ra/.cpan/build/DBD-mysql-4.025-T3ACsU/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/ra/.cpan/build/DBD-mysql-4.025-T3ACsU/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
# Referenced from: /Users/ra/.cpan/build/DBD-mysql-4.025-T3ACsU/blib/arch/auto/DBD/mysql/mysql.bundle
# Reason: image not found at /System/Library/Perl/5.16/darwin-thread-multi-2level/DynaLoader.pm line 194.
# at (eval 8) line 2.
# Compilation failed in require at (eval 8) line 2.
# BEGIN failed--compilation aborted at (eval 8) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255
CAPTTOFU/DBD-mysql-4.025.tar.gz
make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports CAPTTOFU/DBD-mysql-4.025.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
CAPTTOFU/DBD-mysql-4.025.tar.gz : make_test NO
Problem was solved, before make you must to do:
sudo install_name_tool -id /usr/local/mysql-5.6.14-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/local/mysql-5.6.14-osx10.7-x86_64/lib/libmysqlclient.18.dylib
Best regards, German
Hi, I just wonder why can't I install DBD::mysql to my iMac(Mojave). these documents(including the docs I have googled&read) are not enough, maybe wrong.
At least, export DBD_MYSQL_TESTPASSWORD=s3kr1+
must be export DBD_MYSQL_TESTPASSWORD=s3kr1t
And Just installing 'mysql-connector-c' isn't the way to solve it.
Before that, it seems that we have to do like bellow:
brew install mysql- setting up the mysql
mysql> CREATE DATABASE test;mysql> CREATE USER '[your name]'@'localhost' IDENTIFIED BY 's3kr1t';mysql> grant all privileges on test.* to '[your name]'@'localhost';~~identified by 's3kr1t'~~- then
brew unlink mysqlandbrew install mysql-connector-c
and
# perl Makefile.PL --testpassword=s3kr1t --testhost=localhost --testport 3306 in manual installation.
Even if we've done all the above, there is something wrong or less.So I can't install it yet. Somebody, please tell me the way to install it then I will make PR that is fixed the documentations.
Hi, Finally I could install it to my Mac(Mojave) but What I did wasn't in the documents. It was like below:
tar xf DBD-mysql-4.xxx.tar.gz
cd DBD-mysql-4.xxx/
sudo perl Makefile.PL --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient"
sudo make test
sudo make install
- mysql Ver 8.0.12 for osx10.14 on x86_64 (Homebrew)
- perl 5, version 20, subversion 3 (v5.20.3) built for darwin-2level
- mysql-connector-c was not needed.
- without
sudo, Permission denied - without
--libsoption, Makefile.PL stopped with message like below:
Checking if libs are available for compiling...
Can't link/include C library 'ssl', 'crypto', aborting.
What should I do for us?
Could you share the output of
mysql_config/usr/local/Cellar/mysql/8.0.12/bin/mysql_config
I wonder if it reports the correct location for the OpenSSL libraries.
Does it work with sudo perl Makefile.PL --mysql_config=/usr/local/Cellar/mysql/8.0.12/bin/mysql_config?
What version(s) of OpenSSL do you have installed?
Did you try using install_name_tool like in the description of this issue?
Sure! Thank you for replying.
the output of /usr/local/bin/mysql_config is...
Usage: /usr/local/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/Cellar/mysql/8.0.12/include/mysql ]
--cxxflags [-I/usr/local/Cellar/mysql/8.0.12/include/mysql ]
--include [-I/usr/local/Cellar/mysql/8.0.12/include/mysql]
--libs [-L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/Cellar/mysql/8.0.12/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [8.0.12]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/Cellar/mysql/8.0.12/include/mysql]
pkglibdir [/usr/local/Cellar/mysql/8.0.12/lib]
plugindir [/usr/local/Cellar/mysql/8.0.12/lib/plugin]
And, the output of /usr/local/Cellar/mysql/8.0.12/bin/mysql_config is...
Usage: /usr/local/Cellar/mysql/8.0.12/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/Cellar/mysql/8.0.12/include/mysql ]
--cxxflags [-I/usr/local/Cellar/mysql/8.0.12/include/mysql ]
--include [-I/usr/local/Cellar/mysql/8.0.12/include/mysql]
--libs [-L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/Cellar/mysql/8.0.12/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [8.0.12]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/Cellar/mysql/8.0.12/include/mysql]
pkglibdir [/usr/local/Cellar/mysql/8.0.12/lib]
plugindir [/usr/local/Cellar/mysql/8.0.12/lib/plugin]
I Seems the both are same, and --port is wrong.
sudo perl Makefile.PL --mysql_config=/usr/local/Cellar/mysql/8.0.12/bin/mysql_configdidn't work. error message is here:
Checking if libs are available for compiling...
Can't link/include C library 'ssl', 'crypto', aborting.
-
OpenSSL may be the newest, 1.0.2q 20 Nov 2018
-
Yes I did try using
install_name_toollike below:
sudo install_name_tool -id /usr/local/Cellar/mysql/8.0.12/lib/libmysqlclient.21.dylib /usr/local/Cellar/mysql/8.0.12/lib/libmysqlclient.21.dylib
But there is no output.
I'm sorry that I can't understand what it is.
Hi, It seems that I had something wrong.
We don't have to use sudo, because I could reinstall it without sudo.
But also we don't have to install mysql-connector-c. The all I have to install was just only openssl and mysql.
So, I will try to describe the right way.
- cd ~/
- brew install openssl mysql
- setting up the mysql
- mysql> CREATE DATABASE test;
- wget https://github.com/perl5-dbi/DBD-mysql/archive/4_049.tar.gz
- tar xf 4_049.tar.gz
- cd DBD-mysql-4_049
- perl Makefile.PL
- make test
- make install
Before that, you may have to do like below:
sudo install_name_tool -id /usr/local/Cellar/mysql/8.0.13/lib/libmysqlclient.21.dylib /usr/local/Cellar/mysql/8.0.13/lib/libmysqlclient.21.dylib
Somebody, Please try to reproduce it.
-
show mysql_config path by
which mysql_configeg: /usr/local/opt/[email protected]/bin/mysql_config
-
show openssl lib path by
which openssl. note: if it's a symbol in /usr/local/bin, you can typels -ld /usr/local/bin/opensslto show patheg: /usr/local/openssl/bin/openssl so you can insert
-L/usr/local/openssl/lib/to search crypto and ssl libs -
edit
mysql_configfile and insert path of openssl lib(line #114)eg: libs=$libs -L/usr/local/opt/openssl/lib insert path of openssl lib
4.type cpan install DBD::mysql , success.
Using the standard installation instructions I ran into the same issue as @worthmine on MacOS Mojave. The issue appears to be caused by the brew install of openssl being 'keg only'.
The fix that appeared obvious to me, was running brew link openssl. That refuses to run as it's apparently a bad idea, but it does list the LDFLAGS and CPPFLAGS values of:
For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"
I then fixed the issue by adding those values to the variables libs and cflags respectively in /usr/local/bin/mysql_config
Like so;

@dveeden can you update your instructions; it would be helpful...
mysql> grant all privileges on test.* to 'ra1fee'@'localhost' identified by 's3kr1t'; is incorrect, it should be; mysql> grant all privileges on test.* to '[your name]'@'localhost';

Also I found that DBD::mysql does not play well with perl5 that ships with OSX. You need Perl 5.28 and above to avoid header problems. Make it a prerequisite to install DBD::mysql. Please and thank you. https://docs.activestate.com/activeperl/5.28/get/macos/
- show mysql_config path by
which mysql_configeg: /usr/local/opt/[email protected]/bin/mysql_config
- show openssl lib path by
which openssl. note: if it's a symbol in /usr/local/bin, you can typels -ld /usr/local/bin/opensslto show patheg: /usr/local/openssl/bin/openssl so you can insert
-L/usr/local/openssl/lib/to search crypto and ssl libs- edit
mysql_configfile and insert path of openssl lib(line #114)eg: libs=$libs -L/usr/local/opt/openssl/lib insert path of openssl lib
4.type
cpan install DBD::mysql, success.
This is the correct approach. However my environment was telling me the wrong openssl file on which openssl. > /usr/bin/openssl
When in fact the lib i needed for openssl was here: > ▶ /usr/local/Cellar/[email protected]/1.1.1d/lib
following some of the advice above, i was able to resolve this by doing the following:
brew link opensslto reveal info about openssl- copied the value suggested for LDFLAGS e.g.
export LDFLAGS="-L/usr/local/opt/[email protected]/lib" which mysql_configto find location of mysql_config for editing- searched for
"$libsand added-L/usr/local/opt/[email protected]/libafter it sudo cpan DBD::mysql- GREAT SUCCESS!
Hi, now I could install again to my new environment. So I describe the minimal digest.
- Mac OS X 10.14.6 BuildVersion: 18G84
- perl 5, version 32, subversion 0 (v5.32.0) built for darwin-thread-multi-2level
- mysql Ver 15.1 Distrib 10.4.13-MariaDB, for osx10.14 (x86_64) using readline 5.1
$ brew install openssl
$ mysql -uroot -p
(Enter your passwd for mysql-root)
mysql > CREATE DATABASE test;
mysql > grant all privileges on test.* to '[yourAccountNameOnMac]'@'localhost' identified by 's3kr1t';
mysql > exit
$ cd /tmp
$ wget https://github.com/perl5-dbi/DBD-mysql/archive/4_050.tar.gz
$ tar xf 4_050.tar.gz
$ cd DBD-mysql-4_050/
$ perl Makefile.PL --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -lmysqlclient"
$ make test
$ make install
it seems that
- Now we can ignore if there is mysql or mariadb on your Mac.
- This module needs at least one of them.
I don't know about the newer than Mojave, but it deserves to try. After that, May I edit the POD for macOS?
- show mysql_config path by
which mysql_configeg: /usr/local/opt/[email protected]/bin/mysql_config
- show openssl lib path by
which openssl. note: if it's a symbol in /usr/local/bin, you can typels -ld /usr/local/bin/opensslto show patheg: /usr/local/openssl/bin/openssl so you can insert
-L/usr/local/openssl/lib/to search crypto and ssl libs- edit
mysql_configfile and insert path of openssl lib(line #114)eg: libs=$libs -L/usr/local/opt/openssl/lib insert path of openssl lib
4.type
cpan install DBD::mysql, success.
This is amazing I was trying so many solutions. but it helped like magic.
macOS: 10.15.6 (19G73) mySql: 8.0.19 ActivePerl: ActivePerl-5.28-macOS
@dveeden @Homqyy I have solved this in the past while trying to install DBD for mysql 5.7. Since I upgraded to 8.0.19 I have been unable to successfully install DBD::mysql. I have tried all the above steps with no avail. My END GOAL is to be able to use Sqitch DB change management, which requires DBD::mysql in order to work. The error I have been getting;
➜ sudo make test
"/usr/local/ActivePerl-5.28/bin/perl-dynamic" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
PERL_DL_NONLAZY=1 "/usr/local/ActivePerl-5.28/bin/perl-dynamic" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .............................. 1/6
# Failed test 'use DBD::mysql;'
# at t/00base.t line 15.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/ra1fee/.cpan/build/DBD-mysql-4.050-0/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/ra1fee/.cpan/build/DBD-mysql-4.050-0/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _mysql_affected_rows
# Referenced from: /Users/ra1fee/.cpan/build/DBD-mysql-4.050-0/blib/arch/auto/DBD/mysql/mysql.bundle
# Expected in: flat namespace
# in /Users/ra1fee/.cpan/build/DBD-mysql-4.050-0/blib/arch/auto/DBD/mysql/mysql.bundle at /usr/local/ActivePerl-5.28/lib/perl5/5.28.1/darwin-thread-multi-2level/DynaLoader.pm line 197.
# at t/00base.t line 15.
# Compilation failed in require at t/00base.t line 15.
# BEGIN failed--compilation aborted at t/00base.t line 15.
Bailout called. Further testing stopped: Unable to load DBD::mysql
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255
Here is what my .zshrc looks like
PATH TO MYSQL
#export PATH=$PATH:/usr/local/mysql/bin
export PATH="$PATH:/usr/local/mysql/bin"
PATH TO PERL & STATE
export PATH=$PATH:/Users/ra1fee/ra1fee/ActivePerl-5.28-macOS
export PATH=/usr/local/ActivePerl-5.28/bin:$PATH
export PATH=/usr/local/ActivePerl-5.28/site/bin:$PATH
For compilers to find openssl
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/usr/local/mysql/lib-L/usr/local/opt/[email protected]/lib"
This is what mysql_config looks like;
➜ /usr/local/mysql/bin/mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Compiler: AppleClang 11.0.0.11000033
Options:
--cflags [-I/usr/local/mysql/include ]
--cxxflags [-I/usr/local/mysql/include ]
--include [-I/usr/local/mysql/include]
--libs [-L/usr/local/mysql/lib -L/usr/local/opt/[email protected]/lib]
--libs_r [-L/usr/local/mysql/lib -L/usr/local/opt/[email protected]/lib]
--plugindir [/usr/local/mysql/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [8.0.19]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/mysql/include]
pkglibdir [/usr/local/mysql/lib]
plugindir [/usr/local/mysql/lib/plugin]
This is what is inside my mysql_config
# Create options
libs="-L$pkglibdir"
libs="$libs -L/usr/local/opt/[email protected]/lib"
cflags="-I$pkgincludedir "
cxxflags="-I$pkgincludedir "
include="-I$pkgincludedir"
What am I missing for this to not compile properly? I do get a false positive when I run install DBD::mysql in CPAN. It tells me the following;
Reading '/Users/ra1fee/.cpan/Metadata'
Database was generated on Fri, 31 Jul 2020 05:55:45 GMT
DBD::mysql is up to date (4.050).
Anything would be greatly appreciated. Thank you.
@natkhan @krisgale @firegiver @Homqyy, I tried the same approach but I can't write to mysql_config nor can I change permission:
$ which mysql_config
/bin/mysql_config
$ which openssl
~/miniconda3/envs/isown/bin/openssl
$ Attempt to write libs="$libs -L~/miniconda3/envs/isown/bin/openssl". File has read permission only
$ chmod 755 /bin/mysql_config
chmod: changing permissions of ‘/bin/mysql_config’: Operation not permitted
For context, I want to install DBD::mysql Perl package for Variant Effect Predictor
$ cd DBD-mysql-4.050
$ perl Makefile.PL
<redacted>
Checking if libs are available for compiling...
Can't link/include C library 'mysqlclient', aborting.
Warning: No success on command[/home/z8jiang/miniconda3/envs/isown/bin/perl Makefile.PL]
DVEEDEN/DBD-mysql-4.050.tar.gz
/home/z8jiang/miniconda3/envs/isown/bin/perl Makefile.PL -- NOT OK
$ mysql_config
Usage: /bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/include/mysql]
--include [-I/usr/include/mysql]
--libs [-L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto]
--libs_r [-L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto]
--plugindir [/usr/lib64/mysql/plugin]
--socket [/var/lib/mysql/mysql.sock]
--port [0]
--version [5.5.65]
--libmysqld-libs [-L/usr/lib64/mysql -lmysqld]
--variable=VAR VAR is one of:
pkgincludedir [/usr/include/mysql]
pkglibdir [/usr/lib64/mysql]
plugindir [/usr/lib64/mysql/plugin]
@zjiang-lji you probably need to sudo the command