MariaDB database connector (dbtype), PHP packages under Debian?

MariaDB database connector (dbtype), PHP packages under Debian?

by David M -
Number of replies: 3

Hello,

I'm a new Moodle user, trying to set up a test Moodle server on Debian (jessie/8.3) for colleagues to use, based on installation instructions from a colleague's home testing setup.

I have installed Moodle 29 (Moodle 2.9.4+ (Build: 20160121)) via git.

The server is running MariaDB (10.0.22) and PHP 5.6.17.

I was trying to install/configure the downloaded Moodle via shell script, using:

SU_CMD="/usr/bin/php admin/cli/install.php \
 --wwwroot=${WEB_URI} --dataroot=${MOODLE_DATA} \
 --dbtype=mysqli --dbhost=localhost \
 --dbname=${WEB_SERVICE} --dbuser=${MOODLE_DB_USER}
--dbpass=${MOODLE_DB_PASSWD} \
 --prefix=mdl_ --fullname='Moodle Demonstration site' --shortname='Moodle demo' \
 --summary='This is a demonstration site for Moodle' \
 --adminuser=${MOODLE_ADMIN_USER} --adminpass=${MOODLE_ADMIN_PASSWD} \
 --adminemail=${MOODLE_ADMIN_EMAIL} \
 --non-interactive --agree-license"
When run as the Apache user, this complained:
"Error, incorrect value "mysqli" for "dbtype"
Via the docs for MariaDB, I  tried changing the dbtype parameter to "mariadb", but this didn't allow the installation to proceed either (I forgot to note the exact error, as it was nearing the end of a long day, but I think it was probably the equivalent to the above, albeit with "mariadb" instead).

I then had a hunch that perhaps the necessary PHP DB connector package might not have already been installed. Installing mariadb-server had brought in:

libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 
libreadline5 libterm-readkey-perl mariadb-client-10.0 mariadb-client-core-10.0 mariadb-common mariadb-server mariadb-server-10.0 mariadb-server-core-10.0
mysql-common

There doesn't seem to be any sort of php5-mariadb* package, so, working on the hunch, I installed php5-mysqlnd (assuming that it provides PHP mysqli connection functionality, although this is the point at which I get uncertain as to what incompatibility differences there now might be between MySQL and MariaDB and their database engines (I think my MariaDB is using InnoDB, is "SHOW ENGINES" the right command to confirm this?)).

This time, I was able to install/configure Moodle seemingly successfully (as far as the command line output went), although it took some time.

However, when I went to load my Moodle web page, it was displaying an error message in a yellow panel, again, along the lines of some sort of DB connectivity/mysqli problem. At that point, it was beyond time to go home, and I forgot to note the error, assuming that I could continue to try to diagnose from that point in the morning.

This morning, I loaded the web page, but this time Moodle seemed to load successfully, with no error message. I had changed absolutely nothing overnight, so this is somewhat confusing!

If my Moodle installation is now working, this is great, but I'm understandably nervous as to whether I have the correct dbtype setting and have installed the appropriate PHP packages. I will try a test reinstallation again at some point, but I don't want to try to move towards an installation for live-use until I'm certain that my settings are correct and will be reliable (ie, we won't need to reboot the server at some point for OS updates and then everything mysteriously stops working when the server processes restart..).

Can anybody offer any advice as to what the correct settings/packages should be?

Many thanks!

Average of ratings: -
In reply to David M

Re: MariaDB database connector (dbtype), PHP packages under Debian?

by Bret Miller -
Picture of Particularly helpful Moodlers

My config.php says:

$CFG->dbtype    = 'mariadb';

In reply to David M

Re: MariaDB database connector (dbtype), PHP packages under Debian?

by Ken Task -
Picture of Particularly helpful Moodlers

+1 to what Bret said ... and a thing I found needed on CentOS (yes, not Debian, but close) ...

Might need to add/edit both of these to config.php

$CFG->dbtype    = 'mariadb';
$CFG->dblibrary = 'native';

No need to restart any services.

MariaDB is supposed to be a drop in replacement to MySQL.

php -m |grep mysql

should show the php extensions PHP knows about related to mysql.  There isn't a specific php driver for MariaDB. 

If you have installed the online manual:

man -k mariadb

Will show what I've mentioned above (at least it does on CentOS)

mysql                (1)  - the MariaDB command-line tool
mysqld               (8)  - the MariaDB server
mysqld_multi         (1)  - manage multiple MariaDB servers
mysqld_safe          (1)  - MariaDB server startup script
mysql_install_db     (1)  - initialize MariaDB data directory
mysql_plugin         (1)  - configure MariaDB server plugins
mysql_secure_installation (1)  - improve MariaDB installation security
mysql.server [mysql] (1)  - MariaDB server startup script
mysql_upgrade        (1)  - check tables for MariaDB upgrade

Commands like SHOW ENGINES; should work on MariaDB just like on MySQL.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: MariaDB database connector (dbtype), PHP packages under Debian?

by David M -

Thanks for your advice.

After some further investigation, I discovered:

  • Yes, I do need to specify "--dbtype=mariadb" in my options to the install script, when I'm using MariaDB.
  • The install script doesn't seem to have an option to allow me to specify the "dblibrary", but 'native' does seem to end up as the setting which gets written into the config.php file after installation anyway.
  • On Debian, at least, I do need to install the php5-mysqlnd package to enable the PHP database connection functionality, and the reason that it wasn't working for me at first is because I had initially forgotten the need to restart Apache after installing the library, oops!

Moodle seems to be working OK for me now, thanks!