spankmaster79
spankmaster79

Reputation: 22193

Change Magento Config to use sockets

my database config has changed so Magento is not able to connect anymore. The connection before worked but now it seems to need a socket config value...

The relevant part in my local.xml config looks like this:

<connection>
   <host><![CDATA[localhost]]></host>
   <username><![CDATA[username]]></username>
   <password><![CDATA[password]]></password>
   <dbname><![CDATA[dbname]]></dbname>
   <active>1</active>
   <model>mysql5</model>
   <initStatements>SET NAMES utf8</initStatements>
   <type>pdo_mysql</type>
</connection>

Since Magento uses PDO here's my testscript code that is able to connect:

$user = 'username';
$pass = 'password';

// PDO Connection
try {
     /* DB CONNECTION */
    $pdoMysql = new PDO('mysql:host=localhost;unix_socket=/tmp/mysql5.sock;dbname=dbname', $user, $pass);

 }
 catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
 }

So basically I need to add "unix_socket=/tmp/mysql5.sock;" somewhere...

Thx

Upvotes: 4

Views: 6534

Answers (2)

Nic
Nic

Reputation: 13733

Change the host as stated, then delete app/etc/use_cache.ser and retry :)

Upvotes: 0

teemitzitrone
teemitzitrone

Reputation: 2260

you simply place the socket path in the <host/> bit

<host><![CDATA[/path/to/mysql.sock]]></host>

Upvotes: 11

Related Questions