Skip to content

Instantly share code, notes, and snippets.

@masudcsesust04
Last active December 3, 2020 17:28
Show Gist options
  • Save masudcsesust04/1084f7ec62bc0e4dc05e1eba34552c3d to your computer and use it in GitHub Desktop.
Save masudcsesust04/1084f7ec62bc0e4dc05e1eba34552c3d to your computer and use it in GitHub Desktop.
ActiveRecord::StatementInvalid - Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

Steps to success

  1. Open MySQL configuration file -
sudo nano /etc/mysql/my.cnf
  1. Scroll to the bottom of file then copy and paste to the bottom of the file
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  1. ctrl + x to to exit input mode

  2. Press enter to save and close nano.

  3. sudo /etc/init.d/mysql restart to restart MySQL.

  4. Done!

@masudcsesust04
Copy link
Author

It looks like you have extra text to the bottom of the file to be removed at the end of the instruction in step 2.

Thanks for pointing this it was a mistake I missed to review. to the bottom of the file should be at added end of the line of step #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment