title: How to connect R to MySQL? Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded
body: <p>I recently installed MySQL on my computer and am trying to connect RStudio to MySQL. I followed instructions in a book as well as instructions <a href="http://mdsr-book.github.io/excerpts/mdsr-dbadmin.pdf" rel="noreferrer">here</a>. However, whenever I use <code>dbConnect()</code> or <code>src_mysql</code> in <code>RStudio</code>, I get this error message:</p>
  
  <pre><code>Error in .local(drv, ...) : 
    Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded: The specified module could not be found
  </code></pre>
  
  <p>For example, I might login to MySQL using the command prompt in Windows </p>
  
  <p><code>mysql -u username -p</code> </p>
  
  <p>and create a database as follows </p>
  
  <p><code>CREATE DATABASE myDatabase;</code> </p>
  
  <p>and then in RStudio:</p>
  
  <pre><code>library(RMySQL)
  db &lt;- dbConnect(MySQL(), dbname = "myDatabase", user = "username", 
             password = "password", host = "localhost")
  </code></pre>
  
  <p>and my response is always that error message listed above. </p>
  
  <p>And if you need it:
  <code>sessionInfo()</code></p>
  
  <pre><code>R version 3.5.2 (2018-12-20)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows &gt;= 8 x64 (build 9200)
  </code></pre>