Diary, artworks and codes
October 20th, 2009

Database connection problem with 1&1 and CakePHP

I recently had to install, for one of my customer, a web application developed using cakePHP. The server was a dedicated from 1&1.

After I filled my database configuration file correctly, the following error occurred :
Warning (2): mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/tmp/mysql5.sock:’ (2) [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 378]
After half an hour banging my head off keyboard, I figured out one thing important : the connexion is persistent…
So you’ll have to edit your app/config/database.php as follow :

class DATABASE_CONFIG {

	var $default = array(
		'driver' => 'mysql',
		'persistent' => true,
		'host' => 'localhost:/tmp/mysql5.sock',
		'login' => 'dboxxxxxxxxx',
		'password' => 'your_password',
		'database' => 'dbxxxxxxxxx',
		'prefix' => '',
	);

	var $test = array(
		'driver' => 'mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'user',
		'password' => 'password',
		'database' => 'test_database_name',
		'prefix' => '',
	);
}

Upload those modifications and save your day.

Bookmark and Share
by Raphael Leray | Posted in Coding, Uncategorized | No Comments » |

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment