Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brjohnson4's avatar

Disable MySQL Strict Mode on Forge

Hi everyone,

I have a forge server that I want to put a relatively old site onto, but I need to disable strict mode in MySQL 5.7. It's not based on laravel, so I can't easily disable it in my config file. How can I disable it on the server itself? I looked at Matt Stauffer's post here (https://mattstauffer.co/blog/how-to-disable-mysql-strict-mode-on-laravel-forge-ubuntu), but there's nothing in my my.cnf file that looks like the "[mysqld] section" he refers to. It's just 2 lines of this: !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/ Any thoughts? Thanks!

0 likes
4 replies
lindstrom's avatar
Level 15

Just add the [mysqld] section to my.cnf.

sudo nano /etc/mysql/my.cnf

The add the following above the includes:

[mysqld]
sql_mode=''

Save then restart mysql

sudo service mysql restart

The only sql mode enabled by default was NO_ENGINE_SUBSTITUTION in versions >= 5.6.6. Prior to 5.6.6, no sql modes were enabled by default.

aurawindsurfing's avatar

Old one but you can do it easier in your database config in Laravel app by setting:

'connections' => [
...

    'mysql' => [
    ...
        'strict' => false,
        ...

    ],

]

Please or to participate in this conversation.