How do I permanently set sql_mode for MySQL/MariaDB?

Linode Staff

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.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct