How to change MySQL mode permanently in MySQL Managed Database?

Posted August 29, 2019 6.7k views

How to change MySQL mode permanently in MySQL Managed Database?
I know that are no way to access as root user or access to MySQL config in managed database. but please show me how or add an option that user can change mode by themeselve.

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
6 answers

I found the work around. Just simply put mode change query first when you connected to database. mean that every connection have to change mode before you do things.
I know it is not good solution but it help me out for now.

  • Yeap, not good, but working solution :) Thanks, bro…

    PHP sample:

    $connect_link = mysqli_connect(...);
    mysqli_query($connect_link, "SET SESSION sql_mode='...';");
    mysqli_query($connect_link, "SET sql_mode='...';");

Hi Kalin,

Unfortunately, this does not work for managed service. Any update from the Digital Ocean team regarding this would be highly appreciated. Maybe I will open the ticket with Digital Ocean and post the reply here.


Hi there, our sincere apologies for the delay in response. For Mysql managed DBaaS, you won’t be able to change the SQL mode yourself because it requires superuser privileges, and our admins are the only super users. Please open a ticket with us and we will have this taken care of for you.


Hi @ardencod3,

You’ll need to edit your my.cnf file. To find where it’s stored first type

locate my.cnf

Once you’ve found it, use your preferred text editor, add the sql-mode variable and specify required SQL modes on a new line under the [mysqld] section:

vim /path/to/file/my.cnf
sql-mode = 'sql-mode-name1,sql-mode-name2'

Where sql-mode is an MYSQL MODE

One done, restart your mysql service.

Kind regards,
Kalin D.

  • Thank Kalin. the solution you gave is the best way to permanent SQL mode change. However, MySQL Managed Database leave you with no option for access config like that.

  • Appreciate you taking the time to answer, but this is for the managed database service (DBaaS).

    I am interested in this as well as we are looking at moving over to this for our apps.

I came across this solution online by Nathaniel Hammond:

The implementation is swift and takes just a couple of seconds or minutes:

  1. Log into your server as root
  2. Get script wget
  3. Make is executable chmod +x
  4. Run the script ./

You can keep the script where you downloaded it for future mods or references or you can rm -rf and delete the shell script.

You will then have MySQL 5.7 without strict mode.

DISCLAIMER: Not sure if it works with version 8.0

Show answer This answer has been marked as resolved by Zehubert.