Servidor não consegue acessar servidor mysql remoto.

1. Servidor não consegue acessar servidor mysql remoto.

Luan P. Coelho
luanpcweb

(usa Debian)

Enviado em 13/04/2015 - 13:58h

Ola,
Tenho um servidor A CentOS com apache, php e mysql rodando nele. Quando rodo um script .php que consiste em conectar em um banco mysql em um serv B remoto ele da erro.
Será que tem haver com alguma configuracao do iptables na parte de OUTPUT ? ou no php.ini que nao esta deixando conectar ao um banco remoto ?
Ja testei em outro servidor local e rodou o script.


  


2. Re: Servidor não consegue acessar servidor mysql remoto.

CASSIO FERRAZ
cassio88

(usa Ubuntu)

Enviado em 13/04/2015 - 16:22h

por favor, o que aparece no log do apache?



3. Re: Servidor não consegue acessar servidor mysql remoto.

Luan P. Coelho
luanpcweb

(usa Debian)

Enviado em 13/04/2015 - 16:56h

cassio88 escreveu:

por favor, o que aparece no log do apache?


Ele mostra esses logs:
/var/log/httpd

[Mon Apr 13 16:56:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/smba/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/agra/tarefa.php on line 19
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/agra/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/agra/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/agroexport/tarefa.php on line 19
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/riomaria/tarefa.php on line 19
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/riomaria/tarefa2.php on line 673
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/riomaria/tarefa2.php on line 673
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/mercurio/tarefa.php on line 19
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/agroexport/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/agroexport/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/xinguara/tarefa.php on line 31
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/riomaria/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/riomaria/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/mercurio/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/mercurio/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/xinguara/tarefa.php on line 32
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/xinguara/tarefa.php on line 32
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/smba/tarefa2.php on line 634
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/smba/tarefa2.php on line 634
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/agra/tarefa2.php on line 673
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/agra/tarefa2.php on line 673
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_connect(): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/smba/tarefa.php on line 19
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/agroexport/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/agroexport/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/mercurio/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/mercurio/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Notice: Undefined variable: connBD in /var/www/smba/xinguara/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /var/www/smba/xinguara/tarefa2.php on line 672
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/smba/smba/tarefa.php on line 20
[Mon Apr 13 16:57:01 2015] [error] [client 192.168.3.100] PHP Warning: mysql_select_db(): A link to the server could not be established in /var/www/smba/smba/tarefa.php on line 20
[Mon Apr 13 16:57:13 2015] [error] [client 192.168.3.16] PHP Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/xinguara/teste.php on line 40
[Mon Apr 13 16:57:13 2015] [error] [client 192.168.3.16] PHP Warning: mysqli::query(): Couldn't fetch mysqli in /var/www/smba/xinguara/teste.php on line 42
[Mon Apr 13 16:57:13 2015] [error] [client 192.168.3.16] PHP Fatal error: Call to a member function fetch_array() on a non-object in /var/www/smba/xinguara/teste.php on line 44
[Mon Apr 13 16:57:16 2015] [error] [client 192.168.3.16] PHP Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '162.248.210.3' (13) in /var/www/smba/xinguara/teste.php on line 40
[Mon Apr 13 16:57:16 2015] [error] [client 192.168.3.16] PHP Warning: mysqli::query(): Couldn't fetch mysqli in /var/www/smba/xinguara/teste.php on line 42
[Mon Apr 13 16:57:16 2015] [error] [client 192.168.3.16] PHP Fatal error: Call to a member function fetch_array() on a non-object in /var/www/smba/xinguara/teste.php on line 44



4. Re: Servidor não consegue acessar servidor mysql remoto.

CASSIO FERRAZ
cassio88

(usa Ubuntu)

Enviado em 13/04/2015 - 20:22h

Luan,
Por favor, vamos começar com o link abaixo, se não der certo, tente o segundo link:
http://www.vivaolinux.com.br/dica/MySQL-Erro-1045-Access-denied-for-user-rootlocalhost
https://dev.mysql.com/doc/refman/5.1/en/problems-connecting.html
Estou postando outro link, feito para windows, mas é só fazer a adaptação. Você notará que as sugestões são semelhantes.
http://www.homehost.com.br/artigos/solucionando_problemas_de_conexao_no_mysql-055.html
Fico no aguardo




5. Re: Servidor não consegue acessar servidor mysql remoto.

Luan P. Coelho
luanpcweb

(usa Debian)

Enviado em 14/04/2015 - 09:08h

Tentei aqui os processo que tem nos links mais não funcionou. Ae fui mexer em outra coisa e achei esse comando que resolveu:

# setsebool -P httpd_can_network_connect=1

Mais valeu mesmo cara :)






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts