Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

DBD::mysql and MariaDB

by 7stud (Deacon)
on Feb 08, 2018 at 06:25 UTC ( [id://1208683]=perlquestion: print w/replies, xml ) Need Help??

7stud has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm trying to install DBD::mysql so that I can use perl's DBI.

  1. OSX 10.13.2
  2. Perl 5.20.2
  3. I installed MariaDB with homebrew because I got errors trying to install from source. MariaDB is located here: /usr/local/Cellar/mariadb/10.2.12/
  4. I use perlbrew, and to install modules I do: $ cpan DBD::mysql.
Here is the error I get when I try to install DBD::mysql:
... ... Test Summary Report ------------------- t/40server_prepare.t (Wstat: 256 Tests: 31 Failed: 1) Failed test: 27 Non-zero exit status: 1 t/40server_prepare_crash.t (Wstat: 11 Tests: 3 Failed: 0) Non-zero wait status: 11 Parse errors: Bad plan. You planned 39 tests but ran 3. t/40server_prepare_error.t (Wstat: 512 Tests: 3 Failed: 2) Failed tests: 1-2 Non-zero exit status: 2 Files=69, Tests=2041, 34 wallclock secs ( 0.52 usr 0.17 sys + 3.90 c +usr 0.77 csys = 5.36 CPU) Result: FAIL Failed 3/69 test programs. 3/2041 subtests failed. make: *** [test_dynamic] Error 255 MICHIELB/DBD-mysql-4.043.tar.gz /usr/bin/make test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports MICHIELB/DBD-mysql-4.043.tar.gz $
Here is some info about my MariaDB install:
$ brew info mariadb mariadb: stable 10.2.12 (bottled), devel 10.3.4 Drop-in replacement for MySQL https://mariadb.org/ Conflicts with: mariadb-connector-c (because both install plugins) mysql (because mariadb, mysql, and percona install the same binaries +.) mysql-cluster (because mariadb, mysql, and percona install the same +binaries.) mysql-connector-c (because both install MySQL client libraries) mytop (because both install `mytop` binaries) percona-server (because mariadb, mysql, and percona install the same + binaries.) /usr/local/Cellar/mariadb/10.2.12 (640 files, 170MB) * Poured from bottle on 2018-01-27 at 00:05:02 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ma +riadb.rb ==> Dependencies Build: cmake ✘ Required: openssl ✔ ==> Options --with-archive-storage-engine Compile with the ARCHIVE storage engine enabled --with-bench Keep benchmark app when installing --with-blackhole-storage-engine Compile with the BLACKHOLE storage engine enabled --with-embedded Build the embedded server --with-libedit Compile with editline wrapper instead of readline --with-local-infile Build with local infile loading support --with-test Keep test when installing --devel Install development version 10.3.4 ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-bui +lt server starting up correctly. MySQL is configured to only allow connections from localhost by defaul +t To connect: mysql -uroot To have launchd start mariadb now and restart at login: brew services start mariadb Or, if you don't want/need a background service you can just run: mysql.server start $
I searched around and it appears there is a DBD::MariaDB, but it isn't on cpan
DBD::MariaDB
I installed from source, but like I expected the DBI module can't find it:
use strict; use warnings; use 5.020; use autodie; use Data::Dumper; use DBI; my $dsn = 'dbi:mariadb:database=my_db;host=localhost'; my $dbh = DBI->connect($dsn, 'root', ''); --output:-- DBD::mariadb initialisation failed: Can't locate object method "driver +" via package "DBD::mariadb" at /Users/7stud/perl5/perlbrew/perls/per +l-5.20.2/lib/site_perl/5.20.2/darwin-2level/DBI.pm line 827.

Replies are listed 'Best First'.
Re: DBD::mysql and MariaDB
by 7stud (Deacon) on Feb 08, 2018 at 07:03 UTC
    Okay! The DBD::MariaDB worked. Here is the necessary line:
    my $dsn = 'DBI:MariaDB:database=my_db;host=localhost'; my $dbh = DBI->connect($dsn, 'root', '');
    The capitalization of "MariaDB" is required and "mysql" doesn't work.
    After unzipping DBD-MariaDB-master.zip, I did a standard install from source:
    $ cd DBD-MariaDB-master $ perl Makefile.PL $ make $ make test $ make install
Re: DBD::mysql and MariaDB
by Spenser (Friar) on Mar 23, 2018 at 11:25 UTC

    I've been struggling to get DBD::mysql or DBD::MariaDB installed. I finally got the MariaDB installed as you have. But when I try to run a simple perl program just to see if it works, I get this error:

    /opt/bin/perl: symbol lookup error: /opt/lib/perl5/5.26/auto/DBD/MariaDB/MariaDB.so: undefined symbol: get_charset_number

    I added line breaks here to make it easier to read. Any ideas how to resolve this problem?

    -Spenser

    That's Spenser, with an "s" like the detective.

      Create an issue in the GitHub repository, we'll look into it.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1208683]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2024-03-28 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found