Debian, MariaDB, Perl and DBD::mysql

Table of contents

Debian, MariaDB, Perl and DBD::mysql
Downloading the Test Program
See Also

Debian, MariaDB, Perl and DBD::mysql

Help (

Help (

        All this as root:

        gpg --keyserver --recv-keys CBCB082A1BB943DB
        gpg -a --export CBCB082A1BB943DB | apt-key add -

        Warning: The next line originally used 'squeeze', not 'wheezy':
        echo "deb wheezy main" >> /etc/apt/sources.list
        sudo apt-get update

        Warning: The next line originally lacked 'libmariadbclient-dev', which contains 'mysql_config', which is needed by DBD::mysql:
        sudo apt-get install mariadb-client mariadb-server mariadb-client-5.5 mariadb-server-5.5 mariadb-server-core-5.5 mariadb-client-core-5.5 libmariadbclient-dev

        Change root password:
        mysql -uroot -e "update user set password=password('newpassword') where user='root'" mysql
        mysqladmin -uroot reload

        Create a database:
        mysqladmin -uroot -pnewpassword create testdb --default-character-set=utf8

        Create a user and give them access to that database:
        mysql -uroot -pnewpassword mysql
        Note: The next line originally used 'testpassword'. I use 'testpass':
        insert into user (host,user,password) values ('localhost','testuser',password('testpass'));
        insert into user (host,user,password) values ('%','testuser',password('testpass'));
        Warning: The next line originally had 17 Ys, and now needs 19 Ys (for MySQL V 5.5.35):
        insert into db values ('%','testdb','testuser','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
        mysqladmin -uroot -pnewpassword reload

        Now I can do:
        mysql -utestuser -ptestpass testdb
        and (at the 'MariaDB [testdb]' prompt):
        show global variables like "version";

Now try, and fail, to install DBD::mysql:

        export DBI_USER
        export DBI_PASS
        export DBI_DSN
        cpanm DBD::mysql
        But this does not work because it defaults to the user logged in to the bash shell. So:

So do this instead:

        Download DBD-mysql-4.026.tgz, untar it and cd into the dir
        Note: The next line does not use 'sudo make install' because I'm running perlbrew:
        perl Makefile.PL --testuser=testuser --testpassword=testpass --testdb=testdb; make; make test; make install

Downloading the Test Program

Works with MySQL, Postgres and SQLite:

The output shows that all 3 database servers just Do The Right thing without the user having to call encode()/decode().

See Also

Installing Oracle's BerkeleyDB and Perl's BerkeleyDB