title: Using PyMySQL, I can't connect to RDS
body: <p>Using <code>PyMySQL</code>, I get <code>pymysql.err.OperationalError: (1045, u"Access denied for user 'my_user'@'&lt;MY_IP_ADDRESS&gt;' (using password: YES)")</code>, however, I can login from the command line or MySQL Workbench using the same credentials on this machine. And, I can connect to <code>localhost</code> using PyMySQL. Here's my sample test code:</p>
  
  <pre><code>import pymysql
  prod_conn = pymysql.connect(
    host='correct-host-name.us-west-2.rds.amazonaws.com',
    user='my_user',
    password='correct_password',
    port=3306,
    database='my_db')
  </code></pre>
  
  <p>However, using <code>mysql -hcorrect-host-name.us-west-2.rds.amazonaws.com -umy_user -pcorrect_password -P3306 -Dmy_db</code> from the command line on the same machine, I get in just fine.</p>
  
  <p>After Googling, I tried checking the grants for the user and I <em>believe</em> that the user is setup correctly. <code>SHOW GRANTS FOR CURRENT_USER()</code> returns</p>
  
  <pre><code>Grants for my_user@%
  'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO \'my_user\'@\'%\' WITH GRANT OPTION'
  </code></pre>
  
  <p>I tried checking <code>SELECT USER(), CURRENT_USER();</code> and get back</p>
  
  <pre><code>USER()                      CURRENT_USER()
  'my_user@&lt;MY_IP_ADDRESS&gt;'   'my_user@%'
  </code></pre>
  
  <p>So, it seems that the user is setup properly, which I suspected since I can connect through other options. I also tried both suggestions from <a href="https://forums.aws.amazon.com/thread.jspa?messageID=707103" rel="nofollow noreferrer">https://forums.aws.amazon.com/thread.jspa?messageID=707103</a> (specifically, using a different parameter group with <code>log_bin_trust_function_creators == 1</code> and using a password without punctuation) to no avail.</p>
  
  <p>I want to use this in a lambda function, so I really want to use PyMySQL to keep this a python only solution rather than trying MySQLDB or another library.</p>
  
  <p>I don't think there are any anonymous users after reviewing <code>SELECT user,host FROM mysql.user;</code></p>
  
  <pre><code>user        host
  'my_user'   '%'
  'mysql.sys' 'localhost'
  'rdsadmin'  'localhost'
  </code></pre>
  
  <p>Appreciate any other thoughts this community might have on how to proceed...</p>