How do I permanently set sql_mode for MySQL/MariaDB?
I'm trying to update sql_mode using phpmyadmin, but every time I do the original values come back and causes problems with my site.
How can I set sql_mode permanently so it doesn't revert to the original values?
1 Reply
To permanently set sql_mode for your MySQL/MariaDB database, you'll want to set the values you want to use for sql_mode in your configuration file located at /etc/mysql/my.cnf. You can do this by adding sql_mode="$InsertValuesHere" under the [mysqld] section, replacing $InsertValuesHere with the values you wish to use.
Once you've updated my.cnf, you'll just need to restart your database by running sudo systemctl restart mysqld on newer distributions or sudo service mysql restart on older distros without systemd.