Skip to content

Instantly share code, notes, and snippets.

@vitorbritto
Created January 24, 2015 17:10
Show Gist options
  • Select an option

  • Save vitorbritto/ffa7b5016fcb45560b59 to your computer and use it in GitHub Desktop.

Select an option

Save vitorbritto/ffa7b5016fcb45560b59 to your computer and use it in GitHub Desktop.
Install MySQL with HomeBrew

Install MySQL with HomeBrew

# Installing MySQL

brew install -v mysql

# Setting up MySQL

# Copy the default my-default.cnf file to the MySQL Homebrew Cellar
# directory where it will be loaded on application start:
cp -v $(brew --prefix mysql)/support-files/my-default.cnf $(brew --prefix)/etc/my.cnf

# This will configure MySQL to allow for the maximum packet size,
# only appropriate for a local or development server.
cat >> $(brew --prefix)/etc/my.cnf <<'EOF'

# Vitor Britto - Changes
max_allowed_packet = 1073741824
innodb_file_per_table = 1
EOF

# Uncomment the sample option for innodb_buffer_pool_size to improve performance:
sed -i '' 's/^#[[:space:]]*\(innodb_buffer_pool_size\)/\1/' $(brew --prefix)/etc/my.cnf

# Now we need to start MySQL using OS X's launchd, and we'll set it to start when you login.
[[ ! -d ~/Library/LaunchAgents ]] && mkdir -v ~/Library/LaunchAgents
ln -sfv $(brew --prefix mysql)/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# By default, MySQL's root user has an empty password from any connection.
# You are advised to run mysql_secure_installation and at least set a password for the root user:
$(brew --prefix mysql)/bin/mysql_secure_installation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment