title: Apche Airflow with MySQL backend - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
body: <p>When I click on the DAG name or show tree view or graph view for active DAGs, I get the following error:</p>
  
  <pre><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/app.py", line 1988, in wsgi_app
      response = self.full_dispatch_request()
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/app.py", line 1641, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/app.py", line 1544, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
      rv = self.dispatch_request()
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask_admin/base.py", line 69, in inner
      return self._run_view(f, *args, **kwargs)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask_admin/base.py", line 368, in _run_view
      return fn(self, *args, **kwargs)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/flask_login.py", line 755, in decorated_view
      return func(*args, **kwargs)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/airflow/www/utils.py", line 219, in view_func
      return f(*args, **kwargs)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/airflow/www/utils.py", line 125, in wrapper
      return f(*args, **kwargs)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/airflow/www/views.py", line 1162, in tree
      DR.execution_date&gt;=min_date)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/orm/query.py", line 3233, in all
      return list(self)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/orm/query.py", line 3389, in __iter__
      return self._execute_and_instances(context)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/orm/query.py", line 3414, in _execute_and_instances
      result = conn.execute(querycontext.statement, self._params)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", line 982, in execute
      return meth(self, multiparams, params)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement
      distilled_params,
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", line 1250, in _execute_context
      e, statement, parameters, cursor, context
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", line 1478, in _handle_dbapi_exception
      util.reraise(*exc_info)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
      raise value
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context
      cursor, statement, parameters, context
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
      cursor.execute(statement, parameters)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/mysql/connector/cursor_cext.py", line 272, in execute
      self._handle_result(result)
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/mysql/connector/cursor_cext.py", line 163, in _handle_result
      self._handle_resultset()
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/mysql/connector/cursor_cext.py", line 651, in _handle_resultset
      self._rows = self._cnx.get_rows()[0]
    File "/home/airflowenv/airflow1/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 318, in get_rows
      else self._cmysql.fetch_row()
  SystemError: &lt;built-in method fetch_row of _mysql_connector.MySQL object at 0x1e9ce60&gt; returned a result with an error set
  </code></pre>
  
  <p>I am using Airflow (version 1.8.1) with MySQL 8 as the backend database. These dags worked when I used sqlite and Oracle. </p>
  
  <p>After some research on stackoverflow I made these changes to airflow config fil but this hasn't resolved the problem.</p>
  
  <pre><code>sql_alchemy_conn = mysql+mysqlconnector://&lt;user&gt;:&lt;password&gt;i@localhost/MIAF?charset=utf8mb4
  
  sql_engine_encoding = utf8mb4
  </code></pre>
  
  <p>How do I resolve this problem?</p>