Using Moodle in YUNOHOST with mysql?

Hello…

another question regarding Moodle in YNH… I’d like to use mysql … but Moodle in YNH is configured to use postGreSQL…

I can change the settings in the config.php but what would be the pb after that ? when upgrading or something ??

I have zero knowledges about this but I’m pretty sure that this kind of changes will lead you to huges problems with each migrations, backups, and maybe user managment.

Why would you want to use MySQL instead of PostgreSQL ?
Usually people prefer to leave MySQL to use PostgreSQL.

Can you elaborate on why you want to use mysql instead of postgresql ?

I was used to host Moodle on a mac os X server… but as Apple decided to stop dev on the server part, I have to migrate my actual Moodle … and as I got a YUNOHOST that works nicely for two years now… I want to migrate it to YNH Moodle… but on mac os X, my database is MySQL… and on YNH it’s PostgreSQL.

as I’m basically a sound/video teacher… I got some basic knowledge about web hosting but not enough to understand all the details (but I can learn…)

Plus, I got to say that YNH already got a MySQL database… as it is used for other YNH packages… like Nextcloud, for instance…

NextCloud have a pull Request opened about migrating to PostgreSQL :grimacing:
I don’t know Moodle at all, but does it contains an import/export feature ?

I really think that you should stick to the database used by the YunoHost package.
If there is no import/export feature, you ca try to export the MySQL tables and import them in PostgreSQL, for most fields it will work (but not for all, so it will require some work)

The documentation of moodle make me think that import/export is possible, this is the path I think is the safest.
https://docs.moodle.org/39/en/Development:Question_import/export_formats
https://docs.moodle.org/39/en/Import_and_export_FAQ

With such big databases, export MySQL and trying to import into PostgreSQL is way too unreliable. … and too much time to check everything… when you got 450 students and all their notes, pass, datas, works, …

There’s an import/export feature in Moodle but only for Moodle content. You’ll need to import/export your database separatly.

BTW, I’ve tried several times to install the PostgreSQL tool (pgadmin) in my YNH (3.8) and it fails all the time… which doesn’t allow me to test things properly between both …(mysql and postgre)

Hi!

I reworked this app for Yunohost, and I must admit that managing multiple RDBMS is very complicated and boring for the packager :slightly_smiling_face:

You can try to migrate from mysql to PostgreSQL: https://docs.moodle.org/39/en/Database_transfer

Hi…

for that, I’ll need PgAdmin to work in YNH… and right now, it refuses to install on YNH 3.8.5.7 …

Hi,

Can you provide logs please :slightly_smiling_face:

Cf can't install PgAdmin... · Issue #8 · YunoHost-Apps/pgadmin_ynh · GitHub
and Can't install PgAdmin...?! - #6 by Josue

yes, that’s it, thank you (:

ok, after a lot of pain, I managed to upgrade to buster… and to install PgAdmin.

I’m gonna try to import my moodle database… But I still can’t figure how… as the link https://docs.moodle.org/39/en/Database_transfer

doesn’t provide much informations… and many tutorials on the net skip essential informations to be useful…

after hours on it… the link : https://docs.moodle.org/39/en/Database_transfer
is, in fact, useless: the experimental tool is not even near alpha state, since 2016 at less. There’s no log, no error return… the GUI, in Moodle, got no information about how to fill in it… There are dozen of topics in moodle website forums with people with the same problem: migrating from MySQL to PostgreSQL… none of them succeed.

samething for the CLI migrate.php … I got a “permission denied” even as root, hahahaha… or a simple “could not open input file” … no -help or -man to have any information … I’ve tried with php 7.0, 7.1, 7.3 …

Sources:
https://moodle.org/mod/forum/discuss.php?d=385396
https://moodle.org/mod/forum/discuss.php?d=362331
https://moodle.org/mod/forum/discuss.php?d=329176

and it goes on, with people asking the same question since 2008…

So, it seems there’s no solution here. It’s impossible to migrate properly from MySQL to PostgreSQL with Moodle…

Of course, i’ll be very happy if someone can prove me wrong…

So, I got to go back to my previous question, why can’t I use the MySQL that is already in YNH ?

It’s not really that you can’t, it’s more that the app package is just not made that way. In Yunohost, we try to provide easy and simple installation, and there would be no point for regular users to choose between mysql and postgresql as the database backend (except that for you it does because what you want to achieve is importing a previous moodle, but very few people are in that situation) - otherwise that turns app install forms into a gigantic bunch of super technical / pointless questions.

You can still technically tweak the package such that it uses mysql instead of postgresql, but the yunohost project can’t help you doing and maintaining that because that’s not the purpose of the project to provide general system administration support about stuff that are not related or maintained by the yunohost people …

yep, I get it… but, as far as I know, the only “thing” that says to the moodle distrib that it’s using this or that dB is the config.php file … except if YNH devs changed more things in the Moodle distrib ? But I don’t really see why nor where… ?

Here, I don’t intend to touch the package at all, except changing the information in the config.php file…

right now, it’s something that looks like:

$CFG->dbtype = ‘pgsql’;
$CFG->dblibrary = ‘native’;
$CFG->dbhost = ‘localhost’;
$CFG->dbname = ‘moodle’;
$CFG->dbuser = ‘moodle’;
$CFG->dbpass = ‘xxxxxxxxxxxxxxxxxx’;
$CFG->prefix = ‘mdl_’;
$CFG->dboptions = array (
‘dbpersist’ => 0,
‘dbport’ => ‘’,
‘dbsocket’ => ‘’,
);

$CFG->wwwroot = ‘https://xxxxx.freeboxos.fr/moodle’;
$CFG->dataroot = ‘/home/yunohost.app/moodle’;
$CFG->admin = ‘admin’;

if I change it to look like the old config file that I got, on my mac, using mysql, and just keep the proper informations, it could be:

$CFG->dbtype = ‘mysqli’;
$CFG->dblibrary = ‘native’;
$CFG->dbhost = ‘localhost’;
$CFG->dbname = ‘moodle’;
$CFG->dbuser = ‘moodle’;
$CFG->dbpass = ‘xxxxxxxxxxxxxx’;
$CFG->prefix = ‘mdl_’;
$CFG->dboptions = array (
‘dbpersist’ => 0,
‘dbport’ => ‘’,
‘dbsocket’ => ‘’,
‘dbcollation’ => ‘utf8mb4_unicode_ci’,
);

$CFG->wwwroot = ‘https://xxxxxx.freeboxos.fr/moodle’;
$CFG->dataroot = ‘/home/yunohost.app/moodle’;
$CFG->admin = ‘admin’;

I understand that you can’t figure out all the situations… and pbs…
but, if can you tell me what could go wrong here ? (except when it’ll come to upgrade, of course, cause I’ll have to replace the config.php file after each upgrade)

Backup/restore/upgrade script won’t work correctly.

For example, this queries are done on pgsql not on mariadb…

The backup script won’t backup your mariadb and will backup the pg db, it’s possible the restore script crash completely. If the change_url script is created for this package, it could failed too, etc.

So you can install moodle by hand in yunohost (or install the package and change the setup) but in this case you should upgrade by hands too.

So you just need to migrate if you want to upgrade/backup/restore with the package

So you just need to migrate if you want to upgrade/backup/restore with the package

yep, except migration from MySql to PostgreSQL, for Moodle, has been tried several times for the last ten years and failed all the time… as said in some of the sources I provided… (I can put them all, but what’s the point ?) … the tool provided in Moodle for migration is in an alpha state for years and no one seems to be able to make it work…

I’m gonna see how to deal with Moodle as a custom web-app in parallel of all of this, as it seems probably the best solution. Right now, for that, I need to access the MariaDB server remotely… and that seems an issue too… (I’ve posted another topic for that)

OK, I’ve finally managed to install Moodle as a custom web_app, with MariaDB (mysql) … a lot of details amazed me (the fact that the “user” in charge is not www-data … but a “my_webapp” user…) and other things… but in the end, I learned a lot and managed to make the whole thing working… I managed to made a welcome webpage at the sametime, and make it work on the same network with a synology without conflict.

…for now (-: I do hope everything’s will be fine, cause I spent nearly 40 or the last 48 hours on that…

I do hope there’ll be an easier way to migrate Moodle cause, during this issue, I’ve read dozen (if hundreds) of topics with people with similar issues…

2 Likes