The Troll's factory

Geekeries & pensées
-->

Désactiver le STRICT MODE dans MariaDB // Disable STRICT MODE in MariaDB

For English readers, see the translated article at the bottom of the French part.

MySQL, c’est bien, c’est gratuit, c’est open, tout ça… Mais ça a ses limites, et notamment un tas de bugs.
Et puis en plus, depuis quelques temps, MySQL a un sacré inconvénient : Oracle.

Mais bon, c’est une longue discussion. Tout ça pour dire que si vous êtes ici c’est très certainement que vous êtes passé à MariaDB ! Très bon choix, je ne peux qu’approuver.

Cependant, notamment si vous êtes sous Debian (peut-être bien sous d’autres distros aussi), votre MariaDB va vous causer tout un tas de problèmes, notamment avec les CMS en vous renvoyant tout un tas d’erreurs que vous ne verriez jamais avec MySQL. C’est parce que le « strict mode » est activé par défaut dans MariaDB.

Et il est plutôt très difficile de comprendre comment le désactiver en cherchant sur Google… En effet les solutions que l’ont trouve nous proposent de modifier le fichier de conf et d’ajouter une ligne « sql_mode =  » etc. … Mais ça ne marche pas.

En fait, ça ne marche pas parce qu’il faut que cette ligne soit dans la section « [mysql] » de votre fichier de conf (qui s’appelle bien souvent my.cnf), sinon cela ne marchera jamais !!

Cherchez donc dans votre my.cnf ceci :

[mysql]

Et ajoutez juste en dessous cette ligne :
sql_mode ="NO_ENGINE_SUBSTITUTION,TRADITIONAL,NO_AUTO_CREATE_USER"

En vérifiant bien évidemment qu’il n’y a pas autre part dans le fichier une ligne « sql_mode=… » qui dit le contraire de ce qu’on vient d’ajouter.
Redémarrez MariaDB… Enjoy !

 

————- English version ———–

MySQL, it’s good, it’s free of charge, it’s open, etc. … But, it has some limitations, and particularly a certain amount of bugs.

Moreover, for a couple a months, MySQL has a serious drawback : Oracle.

But, well, it’s a long discussion. All of this to say that if you’re here reading this very post, it is likely that you’ve gone through MariaDB migration ! Very good choice, I’m forced to approve it.

Although, especially if you are using Debian (maybe in other distros too), your MariaDB will certainly cause you a couple of problems, especially with CMS, throwing lots of SQL errors you would never see with MySQL. It is because the « strict mode » is enable by default in MariaDB.

And it is really difficult to find out how to disable using your googling skills. Indeed the solutions we can find on the Internet suggest to modify the configuration fileto add a ligne « sql_mode=  » etc. … But this does not work.
In fact, this does not work because this ligne must be placed in the « [mysql] » section of your conf file (which is often named my.cnf), else this will never work !!

So, look for this in your my.cnf :

[mysql]

And add this line just after it :
sql_mode ="NO_ENGINE_SUBSTITUTION,TRADITIONAL,NO_AUTO_CREATE_USER"

Of course, checking that there is no other line « sql_mode=… » in the file saying the contrary of what we have just added.
Restart MariaDB… Enjoy !

posté par Troll dans Administration serveur avec aucun commentaire