'Run mysql command in github actions

I am getting mysql error in github actions which I need to fix:

<!-- An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1055 
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xxx'
which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (500 Internal Server Error) -->

To fix this I need to run something like this:

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

My question is where and how do I run this command in github actions yml file ?

jobs:
  main:
    runs-on: ubuntu-latest

    steps:
      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4.28'
          extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
          coverage: xdebug

      - name: Start Mysql
        run: sudo /etc/init.d/mysql start

      - uses: actions/checkout@v1

       ....


Solution 1:[1]

Add additional query in starting mysql:


      - name: Start Mysql
        run: |
          sudo /etc/init.d/mysql start
          mysql -u root --password=mypassword -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 talhaamir