mysqldatagripsql-mode

How to set the SQL Mode on a MySQL connection in JetBrains DataGrip


Does JetBrains DataGrip have any way to allow me to set the SQL_MODE automatically for my connection to a MySQL database?

For example, MySQL Workbench has a specific field for the connection that would set the SQL_MODE. Whilst HeidiSQL provide a way to execute a Startup Script.


Solution

  • In DataGrip, follow these steps.

    1. Go to File > Data Sources and select your connection from the list of Project Data Source.
    2. Go to the Advanced tab which lists a lot of variables.
    3. Locate the the variable named sessionVariables. (Tip: You can search for a particular variable by selecting any variable name, then start typing to seek.)
    4. Set the value for the variable with your SQL mode. For example:

      sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY'