You are here: Problem connecting to MySQL with PEAR::DB and mysqli « PHP « IT news, forums, messages
Problem connecting to MySQL with PEAR::DB and mysqli

Posted by markusjais on 02/17/05 10:47

hello


when connecting to MySQL 4.1 using PHP 5 and PEAR::DB I get this error:

DB Error: connect failed

a closer look gets this:

Can't connect to local MySQL server through socket 'localhost' (2)

the code for the connection is like this::

========
public static function getConnection() {
   $mysql_user = "myname";
   $mysql_password = "secret";
   $mysql_host = "localhost";
  $db_name = "mydb";
   $dsn = "mysqli://$mysql_user:$mysql_password@$mysql_host/$db_name";
   echo $dsn;
   $db = DB::connect($dsn);
   if(DB::isError($db)) {
      echo $db->getMessage();
   }
   return $db;             
}
=======

the DSN looks correct:
and in the php.ini I set the following option:

mysqli.default_socket = /var/lib/mysql/mysql.sock

this is where the socket for mysql access is.
then I restarted apache and mysqld.

the MySQL Server is running. I can connect via mysql on the command line
but not with PEAR::DB.

I am using PHP 5, the latest PEAR::DB, Apache 1.3 on a Redhat 7.3 System.

any ideas what's wrong here ?

Markus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация