Disable MySQL strict mode on cPanel server

Databases | Updated 2026

MySQL/MariaDB strict mode enforces stricter data validation rules. Some older applications and CMS plugins were written without strict mode in mind and throw errors when it is enabled. This guide shows you how to check and disable strict mode on your Ultra Web Hosting account.

Quick Fix

Add this to a .user.ini file in your document root (not supported on all PHP handlers), or ask support to set the SQL mode for your account. The most reliable method on shared hosting is to set it in your application's database connection code.

01. What is MySQL Strict Mode

Strict mode is controlled by the sql_mode variable. When strict mode includes STRICT_TRANS_TABLES or STRICT_ALL_TABLES, MariaDB rejects invalid or missing data instead of silently converting it. For example:

  • Inserting a string into an integer column causes an error instead of inserting 0
  • Inserting a value too long for a column causes an error instead of truncating it
  • A required column with no default value must be explicitly set in INSERT statements

Strict mode is generally a good thing for data integrity, but older applications that rely on MySQL's lenient behavior break when it is enabled.

02. Common Strict Mode Errors

  • SQLSTATE[HY000]: General error: 1364 Field 'xxx' doesn't have a default value
  • Incorrect integer value: '' for column 'xxx'
  • Data truncated for column 'xxx'
  • Out of range value for column 'xxx'

These errors typically appear when installing or running older WordPress plugins, Joomla extensions, or custom PHP applications.

03. How to Check Your Current Mode

Log into phpMyAdmin (cPanel > Databases > phpMyAdmin) and run:

SELECT @@sql_mode;

The result shows a comma-separated list of active modes. If you see STRICT_TRANS_TABLES in the list, strict mode is enabled.

04. How to Disable Strict Mode

Method 1: In Your Application Code (Recommended)

The most reliable method on shared hosting is to set the SQL mode in your application's database connection. This works regardless of server-level settings.

WordPress - add this to wp-config.php before the "That's all, stop editing!" line:

define('DB_COLLATE', '');
// Disable strict mode
$wpdb_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($wpdb_connection) {
    $wpdb_connection->query("SET SESSION sql_mode=''");
    $wpdb_connection->close();
}

Generic PHP - run this immediately after connecting to the database:

$pdo->exec("SET SESSION sql_mode=''");
// or with mysqli:
mysqli_query($conn, "SET SESSION sql_mode=''");

Method 2: Via phpMyAdmin (Temporary)

Run this query in phpMyAdmin to disable strict mode for your current session:

SET SESSION sql_mode = '';
Session vs Global

On shared hosting, you can only change SESSION mode, not GLOBAL. This means you need to set it on every database connection, which is why Method 1 (application code) is the recommended approach.

Method 3: Contact Support

If you need strict mode disabled server-wide for your account, open a support ticket and we can configure it for you.

Better Long-Term Fix

Rather than disabling strict mode entirely, consider fixing the application code to handle data properly. Strict mode catches real bugs - a missing default value or wrong data type is often a sign of a deeper issue that will cause problems later.

Need Database Configuration Help?

If you are unsure which SQL mode settings your application needs, our support team can help configure it.

Open a Support Ticket

Quick Recap: Disabling Strict Mode

  1. Check your current mode with SELECT @@sql_mode; in phpMyAdmin
  2. Set it in your application code with SET SESSION sql_mode=''
  3. For WordPress, add the SET SESSION query in wp-config.php
  4. Contact support if you need it changed at the account level
  5. Consider fixing the app rather than permanently disabling strict mode

4,746 users found this article useful · Last updated March 2026 · Browse all Database articles

  • 4 Users Found This Useful

Was this answer helpful?

Related Articles

Test MySQL Connection

PHP/MySQL | Updated 2026 If your website shows database connection errors, you need to verify...

Server Paths - PHP Perl Python and More

PHP/MariaDB/MySQL | Updated March 2026 The default path to PHP on Ultra Web Hosting servers...

PHP open_basedir Restriction in Effect

PHP/MariaDB/MySQL | Updated March 2026 The open_basedir restriction in effect warning is a...

Learn About MySQL

Databases | Updated 2026 MariaDB (the MySQL-compatible database server on Ultra Web Hosting)...

How can I find my MariaDB - MySQL version?

PHP/MariaDB/MySQL | Updated March 2026 There are several ways to check your MariaDB/MySQL...



Save 30% on web hosting - Use coupon code Hosting30