25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Still confused whether to disable ‘MySQL strict mode’ or not? Eliminate your confusion!

by | Nov 15, 2019

Is it a good idea to disable MySQL strict mode on the server?

Yes! Because many customers are facing with errors like “Field '' doesn't have a default value” while managing some applications.

The root cause of this error is that some software applications like WHMCS do not require MySQL strict mode to be enabled on the server.

At Bobcares, we often get requests from our customers to disable MySQL strict mode as part of our Server Management Services.

Today, let’s get into the details on how our Support Engineers disable MySQL strict mode and fix the related errors.

Reasons for disabling MySQL strict mode

Strict mode controls how invalid or missing values are handled when creating or updating new records on a MySQL database.

By default, MySQL strict mode is active on the server. So, it may arise worrying warnings when a user tries to save records with blank values on certain fields.

As a result, it may not save/update the records which affect the normal operation of a website or web application.

Therefore, Disabling MySQL mode is necessary for certain applications for the proper working. When we disable the MySQL strict mode , it allows queries with missing or invalid values to be executed.

 

How we disable MySQL strict mode

Here, let’s see how our Support Engineers disable MySQL strict mode on the server.

1. initially, we log into the server as a root user.

2. Then, we make sure that if strict mode is enabled on the MySQL server. For that, we log as mysql user.

mysql -u root -p

3. And, we run the following command on a terminal.

SHOW VARIABLES LIKE 'sql_mode';

4. A table with some sql mode values separated by commas will display on the screen as shown below. If it contains “STRICT_TRANS_TABLES” value, it means MySQL strict mode is active now.

5. If so, we create a new configuration file using nano or any other editor.

nano /etc/mysql/conf.d/disable_strict_mode.cnf

6. Next, we enter the below text into the file and save the changes.

[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

7, Also, we restart MySQL service.

service mysql restart

8.  If strict mode is disabled, the output doesn’t contain a value like “STRICT_TRANS_TABLES” after running the below command.

SHOW VARIABLES LIKE 'sql_mode';

This is how we successfully disabled the MySQL strict mode.

In addition, to disable strict mode in cPanel servers, we update the same code as above in /etc/my.cnf.

 

MySQL disable strict mode – How we fixed

At Bobcares, where we have more than a decade of expertise in managing servers, we see that many customers face problems while managing the MySQL server with certain applications.

Now, let’s see the major reasons for MySQL errors and how our Support Engineers fix this error.

 

Incompatible applications

Recently, One of our customers had a MySQL server problem with his web application. While updating some data to the MySQL server, he received an error like,

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of
SELECT list is not in GROUP BY clause and contains nonaggregated column
'yourdbname.tblannouncements.date' which is not functionally dependent on
columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

 

On checking, our Support Engineers found that the MySQL server was running in strict mode and the app wasn’t compatible with strict SQL mode too. So, we disabled the strict mode on the MySQL server.

This solved the error.

 

MySQL service

Similarly, many cPanel customers reported to us that the strict mode showed as enabled after adding the code to disable the strict mode. He added the code
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION in the MySQL configuration file /etc/my.cnf.

Mainly, this occurs when the changes do not take effect after the code has been added to the MySQL configuration file. So, it is necessary to restart the MySQL service. Otherwise, it will only read the configuration files when it initially loads up.

By restarting the MySQL service, we are forcing MySQL to use the new configuration files. For that, we use the following command.

/scripts/restartsrv_mysql

That’s it.

 

[Need assistance disable strict mode? We’ll help you.]

 

Conclusion

In short, some applications like WHMCS needs to disable MySQL strict mode to work properly. Today, we saw how our Support Engineers disabled strict mode for our customers and solved the related errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF