Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can set SQL_MODE permanently on my mac

I'm install MySql on my OsX 10.11 El Capitan. If I try to start my query I have a strange error if my query have Group By.

So if I try to execute this query from Terminal:

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

I can execute my query never problem. Now if I try to re-start my macbook, I have the some problem and I can re-execute the query.

There is any way to fix this sql_mode permanently ?

I have tro to open "etc/mysql/my.cnf" file but there isn't this file on my mac. How can I apply this change ?

like image 522
bircastri Avatar asked Dec 08 '22 15:12

bircastri


2 Answers

You could set my.cnf and add your sql_mode config

  [mysqld]
  sql_mode=ONLY_FULL_GROUP_BY

By default, the OS X installation does not use a my.cnf, and MySQL just uses the default values. To set up your own my.cnf, you could just create a file straight in /etc.

like image 65
ScaisEdge Avatar answered Dec 10 '22 04:12

ScaisEdge


If you're using MAMP PRO it's worth noting this from the guide:

You cannot edit your my.cnf file directly. You must use the MAMP PRO interface to edit your my.cnf file. In the menu go to File > Edit Template > MySQL > my.cnf.

Then you can add the sql_mode you want under the [mysqld] heading. e.g:

[mysqld]
sql_mode=ONLY_FULL_GROUP_BY

This is what worked for me.

like image 32
Toby Beresford Avatar answered Dec 10 '22 03:12

Toby Beresford