How to make sql-mode="NO_ENGINE_SUBSTITUTION" permanent in MySQL my.cnf
Just to add my configuration to the mix, I'm using MySQL 5.7.8 which has the same strict sql_mode rules by default.
-
I finally figured the following working in my /etc/mysql/my.conf:
[mysqld] sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
i.e. dash, not underscore and quotes around the value.
I have NO other my.conf files other than /etc/mysql/my.conf
There are some extra config includes being loaded from /etc/mysql/conf.d/ but they are blank.
And that seems to work for me.
It should be:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
instead of
[mysqld]
sql_mode="NO_ENGINE_SUBSTITUTION"
then restart mysqld service.
Your server may read a different my.cnf
than the one you're editing (unless you specified it when starting mysqld).
From the MySQL Certification Study Guide:
The search order includes two general option files,
/etc/my.cnf
and$MYSQL_HOME/my.cnf
. The second file is used only if theMYSQL_HOME
environment variable is set. Typically, you seet it to the MySQL installation directory. (The mysqld_safe script attempts to setMYSQL_HOME
if it is not set before starting the server.) The option file search order also includes~/.my.cnf
(that is the home directory). This isn't an especially suitable location for server options. (Normally, you invoke the server asmysql
, or asroot
with a--user=mysql
option. The user-specific file read by the server would depend on which login account you invoke it from, possibly leading to inconsistent sets of options being used.)
Another possibility is of course, that your sql-mode
option gets overwritten further down in the same file. Multiple options have to be separated by ,
in the same line.
P.S.: And you need the quotes, IIRC. Now that you've tried it without quotes, I'm pretty sure, you're editing the wrong file, since MySQL doesn't start when there's an error in the option file.
P.P.S.: Had a look at my config files again, there it's
[mysqld]
sql_mode = "NO_ENGINE_SUBSTITUTION"
and it's working.
Woks fine for me on ubuntu 16.04. path: /etc/mysql/mysql.cnf
and paste that
[mysqld]
#
# * Basic Settings
#
sql_mode = "NO_ENGINE_SUBSTITUTION"
For me it was a permission problem.
enter:
mysqld --verbose --help | grep -A 1 "Default options"
[Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
So try to execute the following, and then restart the server
chmod 644 '/etc/mysql/my.cnf'
It will give mysql access to read and write to the file.