📄 mysql_allow_write
字号:
#!/usr/bin/env perl# Use mandatory external modulesuse strict;use Cwd;use File::Basename;use Data::Dumper;use POSIX;use Config;use Time::HiRes;use DBI;# Determine installation dir nameour $SELF_DIR = dirname(dirname(Cwd::abs_path(__FILE__)));# Include parts of the systemrequire $SELF_DIR . '/lib/config.pm';# Read config file and statusour $config = ReadConfig("mmm_agent.conf");print MySqlAllowWrite();exit(0);#-----------------------------------------------------------------sub MySqlAllowWrite($) { my $host = shift; my $this = $config->{this}; # get self connection info my $host = $config->{host}->{$this}->{ip}; my $port = $config->{host}->{$this}->{port}; my $user = $config->{host}->{$this}->{user}; my $pass = $config->{host}->{$this}->{password}; # connect to server my $dsn = "DBI:mysql:host=$host;port=$port"; my $dbh = DBI->connect($dsn, $user, $pass, { PrintError => 0 }); return "ERROR: Can't connect to MySQL (host = $host:$port, user = $user)!" unless ($dbh); # Check server (simple) my $sth = $dbh->prepare("set global read_only=0"); my $res = $sth->execute; return "ERROR: SQL Query Error: " . $dbh->errstr unless($res); $sth->finish; $dbh->disconnect(); $dbh = undef; return "OK";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -