# Install n8n - Open Source Workflow Automation - on MacOS

## What is n8n?

> n8n is an extendable workflow automation tool. With a fair-code distribution model, n8n will always have visible source code, be available to self-host, and allow you to add your own custom functions, logic and apps. n8n's node-based approach makes it highly versatile, enabling you to connect anything to everything. -https://github.com/n8n-io/n8n

## Installing Homebrew Package Manager

1. Start LaunchPad from the dock
2. Search terminal > Click Terminal to launch it
3. Run the following commands in the terminal window
   # if prompted, click install and agree to install command line tools
   # install homebrew
   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
   # enter your password
   # press Enter to continue

## Installing n8n

1. Run the following commands in a terminal window
   # install nodejs
   brew install node@16
   # correct brew link to nodejs v16
   brew unlink node
   brew link --overwrite node@16
   # install mariadb
   brew install mariadb
   # start the mariadb service
   mysql.server start
   # set mariadb service to autostart
   brew services start mariadb
   # connect to the database
   sudo mysql -uroot
2. Run the following commands to create the n8n database and database user
   CREATE DATABASE n8n;
   GRANT ALL ON n8n.* to 'n8n_rw'@'localhost' IDENTIFIED BY 'n8n_N8N!';
   FLUSH PRIVILEGES;
   EXIT;
3. Continue with the following commands:
   # set environmental variables
   export DB_TYPE="mysqldb"
   export DB_MYSQLDB_DATABASE="n8n"
   export DB_MYSQLDB_HOST="localhost"
   export DB_MYSQLDB_USER="n8n_rw"
   export DB_MYSQLDB_PASSWORD='n8n_N8N!'
   export GENERIC_TIMEZONE="America/New_York"
   # install n8n
   sudo npm install n8n --location=global
   # run n8n
   sudo n8n start
4. Open a web browser and navigate to http://DNSorIP:5678
5. Complete the form with an email, first name, last name and password > Click next
6. Complete the questionnaire > Click continue
7. Click Get started
8. Welcome to n8n

Source: https://docs.n8n.io/hosting/installation/npm/