Hace días estoy intentando de resolver este error:
NOTICE: SELECT dbi_link.set_up_connection(
'dbi:mysql:database=webdb;host=192.168.1.106;port=3306',
'root',
'root',
'---
AutoCommit: 1
RaiseError: 1
',
NULL,
NULL,
NULL,
'webdb'
)
NOTICE: SELECT count(*) AS "driver_there"
FROM dbi_link.available_drivers()
WHERE 'dbi:mysql:database=webdb;host=192.168.1.106;port=3306' like '%' || available_drivers || '%'
CONTEXTO: sentencia SQL: «SELECT dbi_link.set_up_connection(
'dbi:mysql:database=webdb;host=192.168.1.106;port=3306',
'root',
'root',
'---
AutoCommit: 1
RaiseError: 1
',
NULL,
NULL,
NULL,
'webdb'
)
»
NOTICE: Warning: something's wrong at line 43.
CONTEXTO: sentencia SQL: «SELECT dbi_link.set_up_connection(
'dbi:mysql:database=webdb;host=192.168.1.106;port=3306',
'root',
'root',
'---
AutoCommit: 1
RaiseError: 1
',
NULL,
NULL,
NULL,
'webdb'
)
»
Resultado de la consulta con 1 filas descartadas.
ERROR: error en la función de Perl «make_accessor_functions»: error en la función de Perl «set_up_connection»: DBI connect('database=webdb;host=192.168.1.106;port=3306','root',...) failed: Can't connect to MySQL server on '192.168.1.106' (13) at line 44 at line 35.
********** Error **********
ERROR: error en la función de Perl «make_accessor_functions»: error en la función de Perl «set_up_connection»: DBI connect('database=webdb;host=192.168.1.106;port=3306','root',...) failed: Can't connect to MySQL server on '192.168.1.106' (13) at line 44 at line 35.
Estado SQL:XX000
Esta es la invocación de la función que arroja el error:
Using sql Syntax Highlighting
- SELECT make_accessor_functions(
- 'dbi:mysql:database=webdb;host=192.168.1.106;port=3306',
- 'root',
- 'root',
- '---
- AutoCommit: 1
- RaiseError: 1
- ',
- NULL,
- NULL,
- NULL,
- 'webdb'
- );
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4
Soy nuevo en Perl, me estrené con esta herramienta de PostgreSQL: DBI-Link. Bueno, esta función es llamada desde otra función (como se ve en el error) pero la línea exacta del error es 46. A continuación la función:
Using sql Syntax Highlighting
- CREATE OR REPLACE FUNCTION dbi_link.set_up_connection(data_source dbi_link.data_source, user_name text, auth text, dbh_attributes dbi_link.yaml, dbi_connection_environment dbi_link.yaml, remote_schema text, remote_catalog text, local_schema text)
- RETURNS integer AS
- $BODY$
- spi_exec_query('SELECT dbi_link.dbi_link_init()');
- my ($params, $quoted);
- foreach my $param (qw(data_source user_name auth dbh_attributes
- dbi_connection_environment remote_schema remote_catalog
- local_schema)) {
- $params->{ $param } = shift;
- IF ( defined $params->{ $param } ) {
- $quoted->{ $param } = $_SHARED{quote_literal}->(
- $params->{ $param }
- );
- }
- else {
- $quoted->{ $param } = 'NULL';
- }
- }
- my $driver = $_SHARED{quote_literal}->(
- $params->{data_source}
- );
- #my $sql = <<SQL;
- #SELECT count(*) AS "driver_there"
- #FROM dbi_link.available_drivers()
- #WHERE available_drivers = $driver
- #SQL
- my $sql = <<SQL;
- SELECT count(*) AS "driver_there"
- FROM dbi_link.available_drivers()
- WHERE $driver LIKE '%' || available_drivers || '%'
- SQL
- warn $sql IF $_SHARED{debug};
- my $driver_there = spi_exec_query($sql);
- IF ($driver_there->{processed} == 0) {
- die "Driver $driver is not available. Can't look at database."
- }
- my $attr_href = LOAD($params->{dbh_attributes});
- warn $dbh IF $_SHARED{debug};
- my $dbh = DBI->connect(
- $params->{data_source},
- $params->{user_name},
- $params->{auth},
- $attr_href,
- );
- IF ($DBI::errstr) {
- die <<ERR;
- Could NOT connect TO DATABASE
- DATA source: $params->{data_source}
- user: $params->{user_name}
- password: $params->{auth}
- dbh attributes:
- $params->{dbh_attributes}
- $DBI::errstr
- ERR
- }
- my @methods = qw(table_info column_info quote);
- foreach my $method (@methods) {
- warn "Checking whether $driver has $method..." IF $_SHARED{debug};
- IF ($dbh->can($method)) {
- warn "$driver has $method <img src="http://perlenespanol.com/foro/images/smilies/icon_smile.gif" alt=":)" title="Smile" />" IF $_SHARED{debug};
- }
- else {
- die (<<ERR);
- DBD driver $driver does NOT have the $method method, which IS required
- FOR DBI-Link TO work. Exiting.
- ERR
- }
- }
- my $sql = <<SQL;
- INSERT INTO dbi_link.dbi_all_connection_info (
- data_source,
- user_name,
- auth,
- dbh_attributes,
- dbi_connection_environment,
- remote_schema,
- remote_catalog,
- local_schema
- ) VALUES (
- $quoted->{data_source},
- $quoted->{user_name},
- $quoted->{auth},
- $quoted->{dbh_attributes},
- $quoted->{dbi_connection_environment},
- $quoted->{remote_schema},
- $quoted->{remote_catalog},
- $quoted->{local_schema}
- )
- SQL
- warn $sql IF $_SHARED{debug};
- my $rv = spi_exec_query(
- $sql
- );
- $sql = <<SQL;
- SELECT
- pg_catalog.currval(
- pg_catalog.pg_get_serial_sequence(
- 'dbi_link.dbi_connection',
- 'data_source_id'
- )
- ) AS "the_val"
- SQL
- warn $sql IF $_SHARED{debug};
- my $result = spi_exec_query($sql);
- IF ($result->{processed} == 0) {
- die "Couldn't retrieve the dbi connection id via currval()!";
- }
- else {
- RETURN $result->{rows}[0]{the_val};
- }
- $BODY$
- LANGUAGE plperlu VOLATILE
- COST 100;
- ALTER FUNCTION dbi_link.set_up_connection(dbi_link.data_source, text, text, dbi_link.yaml, dbi_link.yaml, text, text, text) OWNER TO postgres;
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Puedo conectarme desde la consola al servidor MySQL así:
Using bash Syntax Highlighting
- [root@centos6 mysql]# mysql -h 192.168.1.106 -u root -p webdb
- Enter password:
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 3
- Server version: 5.5.21 MySQL Community Server (GPL)
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
También verifiqué que el puerto esté abierto:
Using bash Syntax Highlighting
- [root@centos6 mysql]# telnet 192.168.1.106 3306
- Trying 192.168.1.106...
- Connected to 192.168.1.106.
- Escape character is '^]'.
- J
- 5.5.21,]rEC\)�Qtwxt^Y$Dkpnmysql_native_passwordConnection closed by foreign host.
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Bueno, he intentado también crear una función para una conexión de prueba y me respondió con el mismo error:
ERROR: error en la función de Perl «probando»: DBI connect('host=192.168.1.106;database=webdb','webdb_user',...) failed: Can't connect to MySQL server on '192.168.1.106' (13) at line 14
********** Error **********
ERROR: error en la función de Perl «probando»: DBI connect('host=192.168.1.106;database=webdb','webdb_user',...) failed: Can't connect to MySQL server on '192.168.1.106' (13) at line 14
Estado SQL:XX000
Ésta es la función:
Using sql Syntax Highlighting
- CREATE OR REPLACE FUNCTION probando()
- RETURNS bit AS
- $BODY$
- USE strict;
- USE DBI;
- my $db_user = "webdb_user";
- my $db_pass = "pass";
- my $host_name = "192.168.1.106";
- my $db_name = "webdb";
- my $q_string = "DBI:mysql:host=$host_name;database=$db_name";
- my $dbh = DBI->connect ($q_string, $db_user, $db_pass,
- {PrintError => 1, RaiseError => 1}) OR die DBI::errstr;
- RETURN 0
- $BODY$
- LANGUAGE plperlu VOLATILE
- COST 100;
- ALTER FUNCTION probando() OWNER TO nsadmin;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Otro intento fue agregarle la sección [client] en my.cnf con el puerto y socket igual que [mysqld] en el servidor: 192.168.1.106.
Desde ya, gracias, perdón por la longitud del mensaje, pero es la única manera que encontré de explicarles mi calvario
Ojalá y puedan ayudarme