Sha256: 6d1254d425f52089b5f4c1deff5507a8a72170923c93f52cc44753f4019221cc

Contents?: true

Size: 1.51 KB

Versions: 13

Compression:

Stored size: 1.51 KB

Contents

module BinInstall
  module Mysql
    def self.install
      puts 'Installing MySQL...'.white
      Brew::Package.install_or_upgrade('mysql')
      Brew::Service.start('mysql')
      Shell.wait(10) # Give MySQL time to spin up.
    end

    def self.install!
      puts 'Installing MySQL...'.white
      Brew::Package.install_or_upgrade!('mysql')
      Brew::Service.start!('mysql')
      Shell.wait(10) # Give MySQL time to spin up.
    end

    def self.create_root
      puts 'Creating root user for MySQL....'.white
      system("mysqladmin --user=root password ''")
    end

    def self.create_root!
      puts 'Creating root user for MySQL....'.white
      BinInstall.system!("mysqladmin --user=root password ''")
    end

    def self.create_user(username, password = nil)
      puts "Creating user #{username} for MySQL...".white
      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)
      puts "Creating user #{username} for MySQL...".white
      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

    def self.installed?
      Shell.executable_exists?('mysql')
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bin_install-0.0.31 lib/bin_install/mysql.rb
bin_install-0.0.30 lib/bin_install/mysql.rb
bin_install-0.0.29 lib/bin_install/mysql.rb
bin_install-0.0.28 lib/bin_install/mysql.rb
bin_install-0.0.27 lib/bin_install/mysql.rb
bin_install-0.0.26 lib/bin_install/mysql.rb
bin_install-0.0.25 lib/bin_install/mysql.rb
bin_install-0.0.24 lib/bin_install/mysql.rb
bin_install-0.0.23 lib/bin_install/mysql.rb
bin_install-0.0.22 lib/bin_install/mysql.rb
bin_install-0.0.21 lib/bin_install/mysql.rb
bin_install-0.0.20 lib/bin_install/mysql.rb
bin_install-0.0.19 lib/bin_install/mysql.rb