393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
# File 'lib/repctl/mysql_admin.rb', line 393
def do_cluster_user(instance)
client = Client.open(instance)
cmd = "DROP USER \'cluster\'@\'localhost\'"
client.query(cmd) rescue Mysql2::Error
cmd = "DROP USER \'cluster\'@\'%\'"
client.query(cmd) rescue Mysql2::Error
if client
cmd = "CREATE USER \'cluster\'@\'localhost\' IDENTIFIED BY \'secret\'"
puts cmd
client.query(cmd)
cmd = "GRANT ALL PRIVILEGES ON *.* TO \'cluster\'@'\localhost\'"
puts cmd
client.query(cmd)
cmd = "CREATE USER \'cluster\'@\'%\' IDENTIFIED BY \'secret\'"
puts cmd
client.query(cmd)
cmd = "GRANT ALL PRIVILEGES ON *.* TO \'cluster\'@\'%\'"
puts cmd
client.query(cmd)
else
puts "Could not open connection to MySQL instance #{instance}."
end
rescue Mysql2::Error => e
puts e.message
puts e.backtrace
ensure
client.close if client
end
|