Question #2269   Submitted by Answiki on 11/21/2021 at 11:06:39 AM UTC

How to permanently set sql_mode in mySQL ?

Answer   Submitted by Answiki on 11/22/2021 at 04:01:08 PM UTC

To permanently set a variable in MySQL, the best option is to add the variable in the configuration file my.cnf usually located in /etc/mysql/. Edit the file and add the following line at the end:

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Then, restart MySQL:

sudo service mysql restart


5 events in history
Answer by Answiki on 11/22/2021 at 04:01:08 PM

To permanently set a variable in MySQL, the best option is to add the variable in the configuration file my.cnf usually located in /etc/mysql/. Edit the file and add the following line at the end:

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Then, restart MySQL:

sudo service mysql restart


Answer by Answiki on 11/21/2021 at 11:20:08 AM

To permanently set a variable in MySQL, the best option is to add the variable in the configuration file my.cnf. Edit the file and add the following line at the end:

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Then, restart MySQL:

sudo service mysql restart


Answer by Answiki on 11/21/2021 at 11:17:05 AM

To permanently set a variable in MySQL, the best option is to add the variable in the configuration file my.cnf. Edit the file and add the following line at the end:

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Answer by Answiki on 11/21/2021 at 11:13:55 AM

To permanently set a variable in MySQL, the best option is to add the variable in the configuration file my.cnf.

Question by Answiki 11/21/2021 at 11:06:39 AM
How to permanently set sql_mode in mySQL ?
# ID Query URL Count

Icons proudly provided by Friconix.