Score:1

Keep MySQL strict mode disabled after server restart (Hostinger VPS with Ubuntu 18.04)

fr flag

So I have a site hosted on VPS Hosting Plan 2 of Hostinger, and it uses MySQL for the database, with the OS of my Virtual Machine being Ubuntu 18.04.

I have to keep MySQL's strict mode disabled globally the entire time for some parts of the site to work. For context, I am only managing the server end at the moment, so I cannot fix the parts of this site that require me to disable strict mode. Those fixes are on the developers' end, and they'll eventually handle them at some point.

Now, the problem I am facing is that when I disable strict mode, it automatically gets enabled after several hours (or a day). This is due to the scheduled server restarts that Hostinger's VPS servers seem to have. Whenever the server restarts, MySQL's strict mode gets re-enabled.

How can I do it so that strict mode is permanently disabled until I turn it back on myself? I obviously don't want to be turning it on every few hours... :)

Edit: I currently used set global sql_mode=''; to disable MySQL strict mode.

djdomi avatar
za flag
how do you disable the mode? is there a administration panel involved?
Syed M. Sannan avatar
fr flag
@djdomi I use the terminal as everyone does. I go into the mysql command line and run a command `set global sql_mode='';`.
Score:2
bs flag

If you disable mysql strict mode using below command, it will get revert after the server restart.

set global sql_mode='';

To set/disable it permanently, you have to edit the value in mysql conf file.

/etc/mysql/my.cnf or /etc/my.cnf based on your OS.

Find the following line:

sql_mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Replace it with the line below: If the line is not found, insert the line under the [mysqld] section (if there is no [mysqld] section, pls create it).

[mysqld] 
sql_mode= ""

Restart the MySQL service for the change to take effect.

Syed M. Sannan avatar
fr flag
Hi, I'll try this today. But If I am not wrong, doesn't running `set global sql_mode='';` under the hood simply change the my.cnf file?
Syed M. Sannan avatar
fr flag
Btw, I have mentioned my OS in the question, it is Ubuntu 18.04. Just letting you know since you said "based on your OS".
Syed M. Sannan avatar
fr flag
You answer works! thanks a lot.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.