Score:0

How to change default SQLite to MySQL for airflow in Ubuntu?

in flag

I want to set up apache airflow with MySQL instead of default SQLite.

I have run this command pip install 'apache-airflow[mysql]', as suggested in the documentation

I have the following info about my system:

  • Ubuntu 22.04.1 LTS on WSL.
Apache Airflow
version                | 2.4.3
executor               | SequentialExecutor
task_logging_handler   | airflow.utils.log.file_task_handler.FileTaskHandler
sql_alchemy_conn       | sqlite:////home/maria/airflow/airflow.db
dags_folder            | /home/myname/airflow/dags
plugins_folder         | /home/myname/airflow/plugins
base_log_folder        | /home/myname/airflow/logs
remote_base_log_folder |


System info
OS              | Linux
architecture    | x86_64
uname           | uname_result(system='Linux', node='LAPTOP-28BMMQV7', release='5.10.102.1-microsoft-standard-WSL2',
                | version='#1 SMP Wed Mar 2 00:30:59 UTC 2022', machine='x86_64')
locale          | ('en_US', 'UTF-8')
python_version  | 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
python_location | /usr/bin/python3


Tools info
git             | git version 2.34.1
ssh             | OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
kubectl         | NOT AVAILABLE
gcloud          | NOT AVAILABLE
cloud_sql_proxy | NOT AVAILABLE
mysql           | mysql  Ver 8.0.31-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
sqlite3         | NOT AVAILABLE
psql            | NOT AVAILABLE


Paths info
airflow_home    | /home/myname/airflow
system_path     | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/ho
                | me/myname/.local/bin
python_path     | /home/myname/.local/bin:/usr/lib/python310.zip:/usr/lib/python3.10:/usr/lib/python3.10/lib-dynload:/hom
                | e/myname/.local/lib/python3.10/site-packages:/usr/local/lib/python3.10/dist-packages:/usr/lib/python3/d
                | ist-packages:/home/myname/airflow/dags:/home/maria/airflow/config:/home/myname/airflow/plugins
airflow_on_path | True


Providers info
apache-airflow-providers-common-sql | 1.3.0
apache-airflow-providers-ftp        | 3.2.0
apache-airflow-providers-http       | 4.1.0
apache-airflow-providers-imap       | 3.1.0
apache-airflow-providers-mysql      | 3.3.0
apache-airflow-providers-sqlite     | 3.3.0

Now when I try to initialise the database, it defaults to SQLite and I don't know how to change it?

myname@LAPTOP-28BMMQV7:/root$ airflow db init
DB: sqlite:////home/maria/airflow/airflow.db
[2022-11-20 16:04:56,628] {migration.py:204} INFO - Context impl SQLiteImpl.
[2022-11-20 16:04:56,628] {migration.py:207} INFO - Will assume non-transactional DDL.
[2022-11-20 16:04:56,955] {migration.py:204} INFO - Context impl SQLiteImpl.
[2022-11-20 16:04:56,956] {migration.py:207} INFO - Will assume non-transactional DDL.
[2022-11-20 16:04:56,956] {db.py:1565} INFO - Creating tables

INFO  [alembic.runtime.migration] Context impl SQLiteImpl.

I can successfully run a MySQL server with sudo service mysql start/stop and create a database from there.

I have a MySQL workbench installed as well.

Can someone tell me how I can initiate MySQL instead of SQLite?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.