<p>Seems this is not a Craft issue at all, but an issue with MySQL connections over PDO. Not sure of the precise environmental conditions that cause this, but I was experiencing the issue on both an AWS EC2 Ubuntu server as well as a MySQL RDS instance.</p>

<p>I discovered the solution here: <a href="https://stackoverflow.com/questions/38809418/unable-to-connect-to-aws-rds-through-pdo">https://stackoverflow.com/questions/38809418/unable-to-connect-to-aws-rds-through-pdo</a></p>

<p>In short, the <code>!</code> in my password was causing the problem. After replacing it with a <code>.</code>, the issue is resolved.</p>

<p>Thanks Amazon...</p>

CC BY-SA 4.0
2019-02-10T23:46:20.517Z
2019-02-10T23:46:20.517Z
Jonny Asmar
<p>I've moved my Craft 3 installation to a new server.</p>

<p>When connecting to the original database, everything works fine.</p>

<p>However, when trying to connect to a new MySQL database (I've tried hosting this on both the new server and RDS) I'm getting the error: <code>Access denied for user</code>. I migrated to the new database by exporting via the Craft CP and then importing to the new database via MySQL Workbench.</p>

<p>I've tried connecting to both servers using a vanilla PHP connection (i.e. <code>new mysqli(host, username, password)</code> and it works perfectly fine -- I can even query the database and return results.</p>

<p>I only run into this error when the connection is opened by the original Craft <code>index.php</code> (the one with the <code>$app-&gt;run()</code> command). I've checked the output of the <code>(new Dotenv\Dotenv(CRAFT_BASE_PATH))-&gt;load();</code> line and it does properly return the settings defined in <code>.env</code>, which are the same as the ones used in the vanilla connection I mentioned above.</p>

<p>The side-effect of this error in <code>storage/logs/phperrors.log</code> is <code>Allowed memory size of &lt;memory_limit&gt; bytes exhausted ... in /var/www/craft/vendor/yiisoft/yii2/db/Connection.php</code>.</p>

<craft3><database><migration><mysql><aws>
MySQL "Access denied for user" after moving to new server
# MySQL "Access denied for user" after moving to new server

(Asked by: username_0 on 2019-02-10)

I've moved my Craft 3 installation to a new server.

When connecting to the original database, everything works fine.

However, when trying to connect to a new MySQL database (I've tried hosting this on both the new server and RDS) I'm getting the error: `Access denied for user`. I migrated to the new database by exporting via the Craft CP and then importing to the new database via MySQL Workbench.

I've tried connecting to both servers using a vanilla PHP connection (i.e. `new mysqli(host, username, password)` and it works perfectly fine -- I can even query the database and return results.

I only run into this error when the connection is opened by the original Craft `index.php` (the one with the `$app->run()` command). I've checked the output of the `(new Dotenv\Dotenv(CRAFT_BASE_PATH))->load();` line and it does properly return the settings defined in `.env`, which are the same as the ones used in the vanilla connection I mentioned above.

The side-effect of this error in `storage/logs/phperrors.log` is `Allowed memory size of  bytes exhausted ... in /var/www/craft/vendor/yiisoft/yii2/db/Connection.php`.

**Tags:** craft3, database, migration, mysql, aws

---

## 1 answers

### Answer by username_0 on 2019-02-10. Score: 2

Seems this is not a Craft issue at all, but an issue with MySQL connections over PDO. Not sure of the precise environmental conditions that cause this, but I was experiencing the issue on both an AWS EC2 Ubuntu server as well as a MySQL RDS instance.

I discovered the solution here: <https://stackoverflow.com/questions/38809418/unable-to-connect-to-aws-rds-through-pdo>

In short, the `!` in my password was causing the problem. After replacing it with a `.`, the issue is resolved.

Thanks Amazon...


---

