Skip to content

Instantly share code, notes, and snippets.

@jjpeleato
Last active May 3, 2021 10:24
Show Gist options
  • Save jjpeleato/96afa990d94fb12974d207fedfeae063 to your computer and use it in GitHub Desktop.
Save jjpeleato/96afa990d94fb12974d207fedfeae063 to your computer and use it in GitHub Desktop.
Disable strict MySQL or MariaDB mode for WordPress
#!/bin/bash
#
# Disable strict MySQL or MariaDB mode for WordPress.
#
# Look at:
# - Find "$incompatible_modes" variable on "./wp-includes/wp-db.php"
#
# Notes:
# - root user is assumed
# - MySQL 5.7+ is assumed
# - MariaDB 10+ is assumed
# - UNIX target environment
#
# Run:
# - wget https://gist.githubusercontent.com/jjpeleato/96afa990d94fb12974d207fedfeae063/raw/414de296fe0959d17f34a55476b60d42b2d29d74/disable-strict-mode-wordpress.sh
# - chmod +x disable-strict-mode-wordpress.sh
# - ./disable-strict-mode-wordpress.sh
#
# Inspired by: https://gist.github.com/nfourtythree/90fb8ef5eeafdf478f522720314c60bd
#
DISABLE="ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
if [ -e /etc/mysql/conf.d/disable_strict_mode.cnf ]; then
echo "Disable strict mode config already exists"
else
echo "Creating file..."
touch /etc/mysql/conf.d/disable_strict_mode.cnf
echo "Adding config..."
printf "[mysqld]\nsql_mode=$DISABLE\n" > /etc/mysql/conf.d/disable_strict_mode.cnf
echo "Done! You must restart the MySQL or MariaDB service"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment