I need a variable to hold results retrieved from the database. So far this is basically what I\'m trying with no success.
myvariable=$(mysql database -u $use
Other way:
Your Script:
#!/bin/sh
# Set these variables
MyUSER="root" # DB_USERNAME
MyPASS="yourPass" # DB_PASSWORD
MyHOST="yourHost" # DB_HOSTNAME
DB_NAME="dbName"
CONTAINER="containerName" #if use docker
# Get data
data=$($MyHOST -u $MyUSER -p$MyPASS $DB_NAME -h $CONTAINER -e "SELECT data1,data2 from table_name LIMIT 1;" -B --skip-column-names)
# Set data
data1=$(echo $data | awk '{print $1}')
data2=$(echo $data | awk '{print $2}')
# Print data
echo $data1 $data2