Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nfourtythree/90fb8ef5eeafdf478f522720314c60bd to your computer and use it in GitHub Desktop.
Save nfourtythree/90fb8ef5eeafdf478f522720314c60bd to your computer and use it in GitHub Desktop.
Serverpilot - Disable Strict SQL Mode in MySQL 5.7
#!/bin/bash
if [ -e /etc/mysql/conf.d/disable_strict_mode.cnf ]; then
echo "Disable strict mode config already exists"
else
touch /etc/mysql/conf.d/disable_strict_mode.cnf
echo "Creating file..."
echo "Adding config..."
printf "[mysqld]\nsql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\n" > /etc/mysql/conf.d/disable_strict_mode.cnf
echo "Restarting MySql..."
service mysql restart
echo "Done"
fi

How To Disable Strict SQL Mode in MySQL 5.7

I wrote a quick script for those that provision servers often enough.

To get this to work take the following steps

  1. Log into your server as root
  2. Get script wget https://gist.githubusercontent.com/nfourtythree/90fb8ef5eeafdf478f522720314c60bd/raw/disable-strict-mode.sh
  3. Make is executable chmod +x disable-strict-mode.sh
  4. Run the script ./disable-strict-mode.sh
  5. ??
  6. MySQL without strict mode (profit)

Hope at least one person finds this useful.

@waderin1987
Copy link

Dude I tried this guide in my puTTY via php 5.6 and it worked like charm, you are genius seriously. God bless u 👍

@nfourtythree
Copy link
Author

@waderin1987 no worries! Glad it worked for you

@ppurohit90
Copy link

Bro awesome work... i have tried many things but you have made it very simple and easy thank you..

@lindsaymasten
Copy link

You are my favorite person, thank you!

@angelfplaza
Copy link

Thank you!

@IniAku
Copy link

IniAku commented Apr 26, 2021

Not working with MariaDB version 10.3.25 :( any clue?

@nfourtythree
Copy link
Author

@IniAku unfortunately not. I don't have a need for this anymore and therefore haven't tried it in a long time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment