Skip to content

Instantly share code, notes, and snippets.

@neilgilmour
neilgilmour / README.md
Last active May 29, 2019 21:34 — forked from scottpnelson/README.md
Automatic MySQL database setup for Roots projects from .env file contents.

About

This script is a fork which is tweaked to work with a typical Trellis + Bedrock project. It will automatically create a new MySQL database for you by reading your MySQL database name, host name, and user credentials from your .env file. This allows you to keep your database details safe, in a single location. This is useful in a development environment where you're using Trellis to provision and deploy to staging and production, but using something like Valet to serve your site locally.

Installation

  1. Download setup_mysql.sh to your site/scripts/ directory
  2. You can modify setup_mysql.sh to set the following:
    • ENV_FILE (the relative path to your .env file -- e.g. ENV_FILE="./.env.local")
  • DEFAULT_MYSQL_HOST (the host name of your MySQL server -- e.g. "localhost")