Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nternetinspired/e93ab68aec188ef7f989d4c31421efe8 to your computer and use it in GitHub Desktop.
Save nternetinspired/e93ab68aec188ef7f989d4c31421efe8 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.

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