Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find and disable MySQL strict mode?

Hello everybody I wanted to find this mysql strict mode for whmcs and disable it but i didn't had a progress I'm a newbie so sry if I didn't mention other things Can anyone help me? I'm working on WHM/Cpanel

like image 930
Hamed Atae Avatar asked Jun 22 '16 09:06

Hamed Atae


People also ask

How do I tell if MySQL has strict mode?

SHOW VARIABLES LIKE 'sql_mode'; If result has "STRICT_TRANS_TABLES", then it's ON. Otherwise, it's OFF. If on then for what modes and how to off.

What is strict mode in MySQL?

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE . A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range.

How do I turn off InnoDB strict mode?

You can also enable or disable InnoDB strict mode at run time with the statement SET [GLOBAL|SESSION] innodb_strict_mode= mode , where mode is either ON or OFF . Changing the GLOBAL setting requires the SUPER privilege and affects the operation of all clients that subsequently connect.


2 Answers

To turn off (or on) mysql strict access from cpanel.

1, search for 'phpmyadmin', in the search box, click on it

2, once phpmyadmin is loaded up, click on the 'variables' tab

3, search for 'sql mode'

then

to turn strict mode on enter

STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION

to turn strict mode off, enter

NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

If you have control of the script you'll be using then it's a good idea to leave strict mode on, it'll alert you to any bugs in your code before they become an issue down the line.

like image 105
Coz Avatar answered Sep 28 '22 00:09

Coz


I currently run a Centos 6.9 server with MariaDB and a multi-cpanel configuration, so for clients, they were unable to disable strict on their own without getting a lack of permission error. This is how you disable it globally:

Open SSH/Console and verify the current mode:

# mysql -e "SELECT @@sql_mode;"

+----------------------------------------------------------------------+
| @@sql_mode                                                           |
+----------------------------------------------------------------------+
|STRICT_TRANS_TABLES, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, |
|NO_ENGINE_SUBSTITUTION                                                |
+----------------------------------------------------------------------+

Locate and edit the "my.cnf" file

vim /etc/my.cnf

Find and change the following or add the line if it's not present

Strict Mode Enabled:

sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Strict Mode Disabled:

sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Restart the MySQL Service

/etc/init.d/mysql restart

Verify strict mode has been disabled:

# mysql -e "SELECT @@sql_mode;"

+--------------------------------------------+
| @@sql_mode                                 |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+

Done :)

like image 30
Shane Dolim Avatar answered Sep 28 '22 01:09

Shane Dolim