|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Always have a "MDB2 Error: connect failed" trying to connect to MYSQL
Hi,
I´m always having "MDB2 Error: connect failed" error when I try to connect to MYSQL database using MDB2. I´m just trying to do the basic sample from PEAR works. This is the code. <?php require_once 'MDB2.php'; $dsn = array( 'phptype' => 'mysql', 'username' => 'lasar', 'password' => 'lasar', 'hostspec' => 'localhost', 'database' => 'secs', ); $options = array( 'debug' => 2, 'portability' => MDB2_PORTABILITY_ALL, ); // uses MDB2::factory() to create the instance // and also attempts to connect to the host $mdb2 =& MDB2::connect($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } ?> all the parameter for the connection are ok, I use this parameter to connect to the database using EMS to MYSQL. I alreasy have tried to connecti using DSN but I have the same error. Please, someone could help me to solve this problem. Thanks. |
|
#2
|
|||
|
|||
|
RE: Always have a "MDB2 Error: connect failed" trying to connect to MYSQL
Another point!
When I try to connect to a no local database server, the connection works, but when I try to connect to a localhost database it isn´t work. |
|
#3
|
|||
|
|||
|
RE: Always have a "MDB2 Error: connect failed" trying to connect to MYSQL
I'm encountering the same problem. Does anyone have a solution to propose?
|
|
#4
|
|||
|
|||
|
RE: Always have a "MDB2 Error: connect failed" trying to connect to MYSQL
Localhost mysql server could be accessed in two ways: via TCP/IP or via socket.
Remote mysql server could be accessed only via TCP/IP. If your remote connection works, but localhost not, there should be some parametr to fill in the $dsn array to specify that you would like to use the socket way of connection... |
|
#5
|
|||
|
|||
|
RE: Always have a "MDB2 Error: connect failed" trying to connect to MYSQL
Try using 127.0.0.1 for the hostname - this solved the issue for me ... looks like a bad DNS resolution problem
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Always have a "MDB2 Error: connect failed" trying to connect to MYSQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|