Different Mysql server error than I configured

Asked

Viewed 28 times

0

I am using PHP and tried to connect to a different server than the one the site is running, using the function:

$servidor = "example.com";
$usuario = "meu_usuario";
$senha = "senha";
$conecta = mysql_connect($servidor, $usuario, $senha) or print(mysql_error());

And makes the mistake

Access denied for user 'meu_usuario'@'outro_servidor.com.br'

It seems he can’t see the server I’m trying to reach.

No matter which server I put in the $server variable, whenever what appears in the error is that it tried to connect to the current server. I don’t use a database on the same server because I don’t have access to it.

  • 1

    The server’s Mysql needs to be configured to give access to meu_usuario@servidor_que_está_hospedado_o_site.

  • That’s not it, on another server the connection works normally, the problem is that the server I’m using seems to force the domain to use itself. Permits are correct now. The problem is that I try to connect to the server "X" but error saying that it was not possible to connect to the server "Y".

  • 1

    @rafaslide see the answer I gave in the linked question, to see how to authorize the user. The problem is the authorization in both cases, test authorize the user on the Mysql server, which probably the error is solved.

  • 2

    @rafaslide but if doing the authorization the problem is not solved, add the details here. PS: Indicating as duplicate does not invalidate your question, it is only a means to point to the solution presented earlier, as a way of organization of the site. This does not mean that your question has problems, rest assured. And if your need IN FACT is different from that, you can edit the question in more detail. (but I would suggest trying the solution presented there, great chance to be what you need).

  • the problem is: I am trying to connect to the server "example.com", when I do the request it returns a Mysql error saying "Access denied for user 'usuario'@'servorestranho.com.br'" ie I am wanting to connect to a server, but who is receiving the connection is another server.

  • 1

    No, the message says you’re trying to connect from the servorestranho.com.br, which is where your website is. There in example.com you need to authorize the user meu_usuario to access from there (therefore meu_usuario@servor_que_está_hospedado_o_site).

  • 2

    Now yes I understand, sorry for the difficulty. I will try and put here a feedback.

  • No problem! I hope you can solve it now.

  • It did not roll, I put the return address in the error in the cPanel Remote Mysql permissions of the server that will receive the data. There was already an entry for '%', anyway I put the address but could not. Continues the same error.

  • 1

    @rafaslide Try creating another user with a new password to make sure that the problem is not credentials. Also, remember to give permissions to this user.

  • Okay, I’ll try tomorrow just, for today I have no more time. Thank you, as soon as I get an answer I come here

  • 1

    The problem was the password, it had many special characters. Thanks for the help!

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.