title: Escaping out password variable with special characters for mysqldump
body: <p>I'm trying to create a shell script to automatically backup my whole database. My script expects the password in a new line because I don't want to store it anywhere. Here is my code:</p>
  
  <pre><code>#!/bin/bash
  echo -n Password:
  read -s PASS
  echo
  docker exec db /usr/bin/mysqldump --all-databases -u admin --password='\''$PASS\'' &gt; backup-$(date "+%Y-%m-%d").sql
  </code></pre>
  
  <p>The problem is, that I need to put the variable into single quotes because of the $ signs in the password, but I can't read variables in single quotes.
  I know there are several similar questions out there, but I could not solve is with them. </p>
  
  <p>So if the password is '$ecretPa$$word', then the actual executed program should be something like this:</p>
  
  <pre><code>docker exec db /usr/bin/mysqldump --all-databases -u admin --password='$ecretPa$$word' &gt; backup-2020-03-03.sql
  </code></pre>