# Mysql problem

**URL:** <https://forum.mautic.org/t/mysql-problem/28395>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [June 22, 2023, 8:18am UTC](https://forum.mautic.org/t/mysql-problem/28395 "2023-06-22T08:18:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wph524](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wph524](https://forum.mautic.org/u/wph524)\
**Post date:** [June 22, 2023, 8:18am UTC](https://forum.mautic.org/t/mysql-problem/28395/1 "2023-06-22T08:18:15Z")

</div>

**Your software**  
My Mautic version is:4.4.9  
My PHP version is: 8.0.29  
My Database type and version is:  
mysql:8.0.27  
**Your problem**  
My problem is:  
cannot connect to sql server  
These errors are showing in the log:  
An error occured while attempting to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ‘user’@‘172.19.0.6’ (using password: YES)  
Steps I have tried to fix the problem: No

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [June 22, 2023, 8:21am UTC](https://forum.mautic.org/t/mysql-problem/28395/2 "2023-06-22T08:21:07Z")

</div>

Hi, check your access to the DB and make sure config is properly added.  
The file you need to edit: MAUTICFOLDER/app/config/local.php

Is the database on local or remote?

Joey

---

<div class="post-metadata">

**Author:** ![wph524](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wph524](https://forum.mautic.org/u/wph524)\
**Post date:** [June 22, 2023, 9:54am UTC](https://forum.mautic.org/t/mysql-problem/28395/3 "2023-06-22T09:54:00Z")

</div>

The database is on a local docker container.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [June 22, 2023, 9:56am UTC](https://forum.mautic.org/t/mysql-problem/28395/4 "2023-06-22T09:56:10Z")

</div>

Okay, not my table. ☹ I hope a docker person will chime in.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [June 22, 2023, 3:43pm UTC](https://forum.mautic.org/t/mysql-problem/28395/5 "2023-06-22T15:43:47Z")

</div>

Where is the source (PHP)? Another container or host?

You user probably does not have the permission to connect from the source you are connecting. You have to add a user with correct host (in case where you run php in docker container this is the name of the container). In case php (mautic source) is on the host you can add user that is allowed to connect from anywhere (%).

Check the docs for a syntax of create user: \< [https://dev.mysql.com/doc/refman/8.0/en/create-user.html](https://dev.mysql.com/doc/refman/8.0/en/create-user.html) \>.

---

<div class="post-metadata">

**Author:** ![wph524](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wph524](https://forum.mautic.org/u/wph524)\
**Post date:** [June 23, 2023, 12:53am UTC](https://forum.mautic.org/t/mysql-problem/28395/6 "2023-06-23T00:53:58Z")

</div>

PHP is installed in Terminal. I think it is not in another container. I can connect to the mysql server in Terminal.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [June 23, 2023, 12:14pm UTC](https://forum.mautic.org/t/mysql-problem/28395/7 "2023-06-23T12:14:56Z")

</div>

OK, I guess you mean php is installed on the host system and mautic app is connecting to a database inside a docker container.

Basically I think what is missing is that your database user that you are using in app/config/local.php does not have permission to connect to database inside a docker container.

I would approach the issue as follows:

- open database port inside container to host (default database port is 3306, but you should verify that is the case in your situation).
- then you I would add user [user@127.0.0.1](mailto:user@127.0.0.1) to mysql.user table (execute the create user and grant privileges) on mysql database inside docker container
- check if I can connect from my host to database inside docker container using mysql-client on the host
- adapt the database details inside app/config/local.php
- clear mautic cache
- check if it works

---

<div class="post-metadata">

**Author:** ![wph524](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wph524](https://forum.mautic.org/u/wph524)\
**Post date:** [June 26, 2023, 12:47am UTC](https://forum.mautic.org/t/mysql-problem/28395/8 "2023-06-26T00:47:42Z")

</div>

Thank you.
