title: MySQL 8.0 + phpMyAdmin + docker [caching_sha2_password error]
body: <p>As mentioned by others (<a href="https://github.com/phpmyadmin/phpmyadmin/issues/14220" rel="nofollow noreferrer">Ref 1</a>,
  <a href="https://stackoverflow.com/questions/49948350/phpmyadmin-on-mysql-8-0">Ref 2</a> and <a href="https://github.com/laradock/laradock/issues/1407" rel="nofollow noreferrer">Ref 3</a>) the current phpMyAdmin version (4.8.2) + MySQL 8.0.11 + PHP 7.2.8 doesn't work as expected.</p>
  
  <p>The error happens when you try to open phpMyAdmin, where it shows an error message:</p>
  
  <pre><code>#2054 - The server requested authentication method unknown to the client
  mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
  mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
  </code></pre>
  
  <p>As stated in MySQL migration manual <a href="https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" rel="nofollow noreferrer">here</a>, and described as the solution in Ref 2, you can correct this by executing the following mysql query inside docker:</p>
  
  <pre><code>ALTER USER root IDENTIFIED WITH mysql_native_password BY 'ROOTPASSWORD';
  </code></pre>
  
  <p>(In order to run this, I use <em>docker exec -it CONTAINERID bash</em> and execute <em>mysql</em> command)</p>
  
  <p>And it works. The main problem is that <strong>I need to fire this query as soon as the container starts</strong> (the current method is manual and far from scalable). I assume it's possible in different ways:</p>
  
  <ul>
  <li>By executing a PHP script that runs the query after everything has been setup (IMO this is unsafe )</li>
  <li>By running the above command in a bash after everything has been setup</li>
  </ul>
  
  <p>The first one is unsafe IMO as the mysql user must have high privileges, although there will be only the root user when this script runs. I haven't tested it yet.</p>
  
  <p>The seconde one is the best IMO, but I can't figure it out how to implement using Dockerfile, as everything I type there runs BEFORE mysql and phpMyAdmin are installed. How could I achieve that?</p>
  
  <p>My current Dockerfile can be seen <a href="https://pastebin.com/cdk8dExz" rel="nofollow noreferrer">here</a> and the docker-compose.yml can be seen <a href="https://pastebin.com/r0stCkUk" rel="nofollow noreferrer">here</a>.</p>