Updated: 11 October 2026 · Applies to: MariaDB 10.6 to 11.4 and MySQL 8
Strict mode makes MySQL and MariaDB reject invalid or oversized values (for example, text longer than its column, or an empty string in a number column) instead of adjusting them with a warning. It is on by default in current MySQL and MariaDB releases. Some older PHP applications were written without it and fail with errors such as Data too long for column or Incorrect integer value.
The better fix is to update the application. If you need to turn strict mode off for an older application, follow these steps as root on your VPS or dedicated server. On shared hosting, open a support ticket instead.
1. Check the current mode
mysql -e "SELECT @@GLOBAL.sql_mode;"
Strict mode is on when the result contains STRICT_TRANS_TABLES or STRICT_ALL_TABLES.
2. Set the mode in the configuration file
Open /etc/my.cnf (on Ubuntu and Debian, the server file under /etc/mysql/, for example /etc/mysql/mariadb.conf.d/50-server.cnf). In the [mysqld] section, add or edit the sql_mode line. Use the value from step 1 without the STRICT_ entries, for example:
[mysqld] sql_mode="ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
3. Restart the database server
# cPanel servers /scripts/restartsrv_mysql # other servers: the service is called mariadb, mysqld or mysql systemctl restart mariadb
Run the command from step 1 again to confirm the new mode.
Test without a restart
As the database root user you can also run SET GLOBAL sql_mode = '...'; with the new value. It applies to new connections only and is lost when the database server restarts, so it is useful for testing before you change the file.