mySQL 8 post flip validation script
mySQL 8 post flip validation script
#!/bin/bash
# MySQL credentials (modify as needed)
MYSQL_USER="your_mysql_user"
MYSQL_PASSWORD="your_mysql_
MYSQL_PORT="3306" # Replace with your MySQL port if necessary
# Get current hostname
CURRENT_HOST=$(hostname)
# Function to execute MySQL queries
execute_mysql_query() {
mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -h"$CURRENT_HOST" -P"$MYSQL_PORT" -e "$1"
}
# Function to get parameter value from my.cnf file
get_param_from_cnf() {
local param_name="$1"
local cnf_file="/etc/mysql/my.cnf" # Adjust path as necessary
if [ -f "$cnf_file" ]; then
local value=$(grep -i "^$param_name\s*=" "$cnf_file" | awk -F "=" '{gsub(/^[ \t]+/, "", $2); print $2}')
echo "$value"
else
echo "my.cnf not found at $cnf_file"
fi
}
# Check read_only parameter in MySQL runtime
read_only_status=$(execute_
# Check super_read_only parameter in MySQL runtime
super_read_only_status=$(
# Check read_only parameter in my.cnf file
read_only_cnf=$(get_param_
# Check super_read_only parameter in my.cnf file
super_read_only_cnf=$(get_
# Output the results
echo "MySQL Runtime Variables on $CURRENT_HOST:"
echo "read_only parameter is set to: $read_only_status"
echo "super_read_only parameter is set to: $super_read_only_status"
echo ""
echo "my.cnf Configuration on $CURRENT_HOST:"
echo "read_only parameter in my.cnf is set to: $read_only_cnf"
echo "super_read_only parameter in my.cnf is set to: $super_read_only_cnf"
Comments
Post a Comment