title: MySQL Access denied from command connection
body: <p>So I'm connecting to an AWS EC2 Ubuntu 16.04 instance. As part of my production script I do:</p>
  
  <p><code>mysql -u root -pmy-secret -e "source resetDb.sql;" &gt;&gt; lastRun.log</code></p>
  
  <p>This <code>resetDb.sql</code> has the queries to create and populate the database info. Then keep on going with the app.</p>
  
  <p>The thing is that mysql is rejecting my access this way by throwing</p>
  
  <p><code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)</code></p>
  
  <p>But if I connect with <code>mysql -u root -p</code> and manually enter the password, it lets me into the console, so this let's me see the password is right. </p>
  
  <p>I get this output on the server</p>
  
  <p><code>$ mysql --version
  mysql  Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using  EditLine wrapper
  $ uname -a
  Linux ip-xx.xx.xx.xx 4.4.0-1038-aws #47-Ubuntu SMP Thu Sep 28 20:05:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  </code></p>
  
  <p>I've seen in another questions about flushing privileges and resetting the root password, but my password is correct so it did no good to me.</p>
  
  <p>Anyone has a clue? The idea is to run the script to automatically setup the whole server. Thanks in advance.</p>