Sha256: 715741cc0becdcecea6ba4581172994b5cc2cf414a11d64d66e78e6594f6c257

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module BinInstall
  module Mysql
    def self.install
      puts 'Installing MySQL...'.white
      Brew.install_or_upgrade('mysql')
      system('brew services start mysql')
    end

    def self.install!
      puts 'Installing MySQL...'.white
      Brew.install_or_upgrade!('mysql')
      BinInstall.system!('brew services start mysql')
    end

    def self.create_root
      system("mysqladmin --user=root password ''")
    end

    def self.create_root!
      BinInstall.system!("mysqladmin --user=root password ''")
    end

    def self.create_user(username, password = nil)
      system(%(mysql --user=root --execute="CREATE USER '#{username}'@'localhost' IDENTIFIED BY '#{password}';"))
      system(%(mysql --user=root --execute="GRANT ALL PRIVILEGES ON *.* TO '#{username}'@'localhost' WITH GRANT OPTION;"))
    end

    def self.create_user!(username, password = nil)
      BinInstall.system!(%(mysql --user=root --execute="CREATE USER '#{username}'@'localhost' IDENTIFIED BY '#{password}';"))
      BinInstall.system!(%(mysql --user=root --execute="GRANT ALL PRIVILEGES ON *.* TO '#{username}'@'localhost' WITH GRANT OPTION;"))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bin_install-0.0.6 lib/bin_install/mysql.rb
bin_install-0.0.5 lib/bin_install/mysql.rb