title: Run "mysql" command from bash script
body: <p>I have a MariaDB Docker container that I want to access automatically with the help of a bash script. </p>
  
  <p>I'm using Docker compose:</p>
  
  <pre><code>version: '3'
  services:
    drupal:
      image: jonasvbogaert/php-docker:${IMAGE_VERSION}
      container_name: drupalenv
      ports:
        - 8080:80
      volumes:
        - /var/www/html/
      restart: always
      environment:
        DRUPAL_SITE_NAME: Drupal
        DRUPAL_USER: admin
        DRUPAL_PASS: admin
    mariadb:
      image: mariadb:latest
      container_name: mariadbenv
      restart: always
      ports:
        - 3036:3036
      depends_on:
        - drupal
      environment:
        MYSQL_ROOT_PASSWORD: ""
        MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        MYSQL_USER: drupal
        MYSQL_PASSWORD: drupal
        MYSQL_DATABASE: drupal`
  </code></pre>
  
  <p>The first command is to dive in the container (works fine):</p>
  
  <pre><code>docker exec -it mariadbenv bash
  </code></pre>
  
  <p>But the second one:</p>
  
  <pre><code>mysql
  </code></pre>
  
  <p>outputs the following error:</p>
  
  <p><code>ERROR 1045 (28000): Access denied for user 'jonasvb'@'localhost' (using password: NO)
  the input device is not a TTY</code></p>
  
  <p>When I enter "mysql" myself, it works.</p>
  
  <p>This is the script I use:</p>
  
  <pre><code>function main () {
    getUserInput
  }
  
  
  function fireDocker () {
    if [ $DRUPAL_VERSION = "7" ]; then                            
      IMAGE_VERSION="drupal7"                                     
      export IMAGE_VERSION                                        
      docker-compose up -d                                         
      mountDump
    else
      IMAGE_VERSION="drupal8"                                     
      export IMAGE_VERSION                                        
      docker-compose up -d                                        
      mountDump
    fi
  }
  
  function getUserInput () {
    echo "Enter Drupal version (7 or 8)"
    read DRUPAL_VERSION                                           # Read 
    fireDocker $DRUPAL_VERSION
  }
  
  function mountDump(){
    docker exec -it mariadbenv bash
    mysql
  
  }
  
  
  main
  </code></pre>
  
  <p>EDIT</p>
  
  <p>When I execute the first command without -t flag.
  I have this: <a href="https://i.stack.imgur.com/ZxqDe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZxqDe.png" alt="enter image description here"></a></p>
  
  <p>And it stays like this.</p>