diff --git a/proxysql-admin b/proxysql-admin index 99770d2..6763746 100755 --- a/proxysql-admin +++ b/proxysql-admin @@ -49,7 +49,7 @@ fi # # Script parameters/constants # -readonly PROXYSQL_ADMIN_VERSION="2.0.13" +readonly PROXYSQL_ADMIN_VERSION="2.0.14" declare -i DEBUG=0 # default timeout is 10 seconds @@ -428,6 +428,7 @@ function exec_sql() { local retvalue local retoutput local default_auth="" + local defaults="" if [[ $# -ge 7 ]]; then args=$7 @@ -444,10 +445,10 @@ function exec_sql() { fi defaults=$(printf '[client]\nuser=%s\npassword="%s"\nhost=%s\nport=%s\nconnect-timeout=%s\n%s' \ - "${user//%/%%}" \ - "${password//%/%%}" \ - "${hostname//%/%%}" \ - "${port//%/%%}" \ + "${user}" \ + "${password}" \ + "${hostname}" \ + "${port}" \ "${TIMEOUT}" \ "${default_auth}" ) diff --git a/proxysql-admin.cnf b/proxysql-admin.cnf index 59a7ad0..ab1b37c 100644 --- a/proxysql-admin.cnf +++ b/proxysql-admin.cnf @@ -12,8 +12,8 @@ export CLUSTER_HOSTNAME='localhost' export CLUSTER_PORT='3306' # proxysql monitoring user. proxysql admin script will create this user in pxc to monitor pxc-nodes. -export MONITOR_USERNAME='monitor' -export MONITOR_PASSWORD='monitor' +export MONITOR_USERNAME='monitor2' +export MONITOR_PASSWORD='m%onitor' # Application user to connect to pxc-node through proxysql export CLUSTER_APP_USERNAME='proxysql_user' diff --git a/proxysql-status b/proxysql-status index 30bf477..ac3b029 100755 --- a/proxysql-status +++ b/proxysql-status @@ -1,5 +1,18 @@ #!/bin/bash -u +declare USER +declare PASSWORD +declare HOST +declare PORT +declare RUNTIME_OPTION="" +declare DUMP_ALL=1 +declare DUMP_MAIN=0 +declare DUMP_STATS=0 +declare DUMP_MONITOR=0 +declare DUMP_FILES=0 +declare TABLE_FILTER="" +declare DUMP_STATS_RESET_TABLE=0 + function usage() { local path=$0 @@ -44,10 +57,20 @@ function mysql_exec() { local query=$2 local retvalue local retoutput - retoutput=$(printf "[client]\nuser=${USER}\npassword=\"${PASSWORD}\"\nhost=${HOST}\nport=${PORT}" \ - | mysql --defaults-file=/dev/stdin --protocol=tcp \ - ${args} -e "${query}") + local defaults="" + local default_auth="" + + defaults=$(printf '[client]\nuser=%s\npassword="%s"\nhost=%s\nport=%s\n%s' \ + "${USER}" \ + "${PASSWORD}" \ + "${HOST}" \ + "${PORT}" \ + "${default_auth}" + ) + + retoutput=$(mysql --defaults-file=<(echo "${defaults}") --protocol=tcp --unbuffered --batch --silent ${args} -e "$query") retvalue=$? + if [[ -n $retoutput ]]; then retoutput+="\n" fi @@ -56,20 +79,6 @@ function mysql_exec() { } -declare USER -declare PASSWORD -declare HOST -declare PORT -declare RUNTIME_OPTION="" -declare DUMP_ALL=1 -declare DUMP_MAIN=0 -declare DUMP_STATS=0 -declare DUMP_MONITOR=0 -declare DUMP_FILES=0 -declare TABLE_FILTER="" -declare DUMP_STATS_RESET_TABLE=0 - - function parse_args() { local go_out=""