I tried adding this line in /etc/mysql/mysql.conf.d/mysqld.cnf
(Ubuntu)
innodb_strict_mode = 1
This is within the [mysqld] section, where I have seen this line in other examples. I know this config file is being read at startup because I get errors if I type in nonsense.
Nevertheless, SHOW VARIABLES lists this variable as OFF and apparently I can insert rows without specifying my non-default fields.
Why isn't this variable being set?
I have tried =on
instead of =1
, no difference. The config is otherwise unmodified from the installation default, AFAIK, full text here.
Best Answer
You can set this
SESSION
variable from the command line:Then, you do this:
Then, to check:
Then, on exiting and reconnecting, and rechecking the variable, it is again OFF - the default. Use
SET GLOBAL innodb_strict_mode = ON
if you don't want it to reset after logging off. But, setting it in the client will not make the change stick after a reboot of the server.Edit
my.cnf
- I've never seen or touchedmysqld.cnf
.Put the line(s) below in the [mysqld] section of my.cnf.
(I recommend the sql_mode line also - otherwise, for example, certain
GROUP BY
queries will return (ahem...) anomalous results).Bounce the server - and relog in.
It's all in the documentation here.
Maybe you don't have the
SUPER
privilege? Log in and runSHOW GRANTS
to find out.