title: Backup Mysql database with shell script - bind-address set to localhost
body: <p>I'm using a shell script to backup my databases from a remote server to my Synology NAS. The script is working fine but when I set the Bind Address in de mysql config @ the remote server to 'localhost', the script isn't working anymore. The script needs a SSH verification. </p>
  
  <p>The question: how can I create the SSH connection / credentials in this script?</p>
  
  <p>Underneath the script I use:</p>
  
  <pre><code>#! /bin/bash
  
  TIMESTAMP=$(date +"%Y-%m-%d")
  PAST=$(date +"%Y-%m-%d" -d "30 days ago")
  BACKUP_DIR="/volume1/dir/dir2/$TIMESTAMP"
  PAST_DIR="/volume1/dir/di2/$PAST"
  HOST="myip"
  MYSQL_USER="username"
  MYSQL=/usr/bin/mysql
  MYSQL_PASSWORD="password"
  MYSQLDUMP=/usr/bin/mysqldump
  
  
  rm -rv $PAST_DIR 
  
  mkdir -p $BACKUP_DIR
  
  databases=`$MYSQL -h $HOST --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
  
  for db in $databases; do
    $MYSQLDUMP --force --opt -h $HOST --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip &gt; "$BACKUP_DIR/$db.sql.gz"
  done
  </code></pre>