PHP/LAMP on Server A, MySQL on Server B - Database connection always tries to connect to Server A

Hi,
I am trying to setup a project on a server:
in ProjectSettings/Targets, I set up Webserver / PHP via SFTP to Server A.
Thats working so far.
I chose this as target.
When I try to set up a Database Connection in Server Actions/Connection Options,
I set MySQL and the Server Adress to the host name of “ServerB” (my MySQL hosted on a different system= Server B).
Used the specific db name and db username correctly.
When I say “Test connection” it always says falsely throw an erro:
“Error using this Database Connection”, Server response Acces denied for user ‘dbuser’@‘serverA’ - instead of @‘serverB’.
Why is that?

It probably is trying to access the correct MySQL server but the user isn’t set up to allow it.

When logging into Mysql, usernames are bound to the address they originate from.
For example:
You could have username@localhost that is only allowed to log in from the machine it is running on.
You could have username@39.118.27.11 which would allow access only from that IP
You could also have username@% where % acts as a wildcard - this would allow access for that user from any machine.

In your example, I think you either need to add a user to the MySQL DB linked to the address of serverB. Alternatively add a wildcard user in MySQL (less secure)

I don’t quite remember what I did to get around it, but I have had the exact same issue.
Very recently too… Unfortunetely, i can’t recollect at all.

Maybe check if server B allows remote connection from server A.

Thanks for your thoughts so far:
@bpj: Thats what I already had (%), I double checked, I was able to access mysql from my local system just fine (all within private net within AWS).

Wow, just while writing this post, I tried it again. I tried to use @localhost in the username and @serverB, didn’t work. But after changing back, it worked. Was just about to update 3.5.1 - and now that :slight_smile: … have no idea, still possible I had a typo somewhere, but I swear I had the message saying user@serverA Access Denied - even though I had the mysql set to serverB, when I changed it to user@localhost (just for testing) and even user@serverB, and now changed it back to just the username, it connected to serverB just fine - out of a sudden. Thats really weird: so if anyone else has that initial trouble try using username@serverB as mysql username (throwing error) and changing it back: @team - maybe you could check if there are some woes with that dialog?

Thank you all!

1 Like

I think I had the same experience. Again, don't recollect completely, but this does look like something I tried too and worked for me.