Module: BinInstall::Mysql
- Defined in:
- lib/bin_install/mysql.rb
Class Method Summary collapse
- .create_root ⇒ Object
- .create_root! ⇒ Object
- .create_user(username, password = nil) ⇒ Object
- .create_user!(username, password = nil) ⇒ Object
- .install(version = nil) ⇒ Object
- .install!(version = nil) ⇒ Object
- .installed? ⇒ Boolean
Class Method Details
.create_root ⇒ Object
25 26 27 28 |
# File 'lib/bin_install/mysql.rb', line 25 def self.create_root puts 'Creating root user for MySQL....'.white system("mysqladmin --user=root password ''") end |
.create_root! ⇒ Object
30 31 32 33 |
# File 'lib/bin_install/mysql.rb', line 30 def self.create_root! puts 'Creating root user for MySQL....'.white BinInstall.system!("mysqladmin --user=root password ''") end |
.create_user(username, password = nil) ⇒ Object
35 36 37 38 39 |
# File 'lib/bin_install/mysql.rb', line 35 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 |
.create_user!(username, password = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/bin_install/mysql.rb', line 41 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 |
.install(version = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/bin_install/mysql.rb', line 3 def self.install(version = nil) puts 'Installing MySQL...'.white if version Brew::Package.install_or_upgrade("mysql@#{version}") else Brew::Package.install_or_upgrade('mysql') end Brew::Service.start('mysql') Shell.wait(10) # Give MySQL time to spin up. end |
.install!(version = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bin_install/mysql.rb', line 14 def self.install!(version = nil) puts 'Installing MySQL...'.white if version Brew::Package.install_or_upgrade!("mysql@#{version}") else Brew::Package.install_or_upgrade!('mysql') end Brew::Service.start!('mysql') Shell.wait(10) # Give MySQL time to spin up. end |
.installed? ⇒ Boolean
47 48 49 |
# File 'lib/bin_install/mysql.rb', line 47 def self.installed? Shell.executable_exists?('mysql') end |