Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • 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.

@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