18

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

0

6 Answers 6

24

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.

1
  • 5
    In cpanel, after one day, will come back changes and will be set again to default value automatically, so I thinks better put sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION into /etc/my.cnf file as this answer: stackoverflow.com/a/47416442/1407491 Aug 15, 2018 at 15:55
12

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 :)

4

First of all, to disable MySQL strict mode, you need server's root access. If you don't have it, you can't do it. If you have just cPanel access, that means, you are not the administrator of this server or you don't have root access.

To edit your mysql configuration file my.cnf, you will have to access your server via SSH (with root user or sudo access) and then edit /etc/my.cnf file and add following line if it is not present:

[mysqld]

sql_mode="TRADITIONAL,NO_AUTO_CREATE_USER"

After editing this file, save it and restart mysql service. Again, you need full root access for your server to change this.

1

I think it is impossible to change *.cnf file in recent version Instead of, you can change mysql.service file

/lib/systemd/system/mysql.service
ExecStart=/usr/sbin/mysqld --sql-mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
0

Open my-default.ini file and remove the STRICT_TRANS_TABLES parameter from sql_mode value.

[Ex: In localhost xampp the file is at xampp/mysql/my-default.ini]

default value of sql_mode is as below

sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

change it to

 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

This will disable the strict mode in MYSQL

5
  • 1
    sry I can't find my.ini where is it? Can u help me?
    – Hamed Atae
    Jun 22, 2016 at 9:52
  • There can be my-default.ini or different file ending with .ini . in MYSQL installation directory Jun 22, 2016 at 10:16
  • Sorry but there is over 100 ini files here
    – Hamed Atae
    Jun 22, 2016 at 10:32
  • It's really getting on my nerves. I only have Cpanel access. How could I find that?
    – Hamed Atae
    Jun 22, 2016 at 10:34
  • I haven't worked on CPanel/whms anytime. If you would have access to mysql installation you could have changed it easily with steps mentioned by me. Jun 23, 2016 at 12:33
0

First, verify which mode(s) MYSQL is running with the below command:

 mysql -u root -p -e "SHOW VARIABLES LIKE 'sql_mode';"

You'll need to replace root with whatever username has superuser permissions on your server (but, it's usually just root). You'll also be prompted for the password.

To Disable Strict Mode via SQL command line:

You can disable strict mode on your MySQL server by running the following command on your command line:

mysql -u root -p -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';"
1
  • This gets reset once mysql restarts Dec 19, 2021 at 13:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.