Knowledgebase: Database
How to fix Drupal when you get an error Can't connect to local MySQL server through socket
Posted by Support, Last modified by Support on 31 January 2011 01:28 PM
You can fix Drupal when you get an error "Can't connect to local MySQL server through socket" by doing one of the following one at a time or a combination of them:


If you are using the MySQL driver then try:
Open your sites/default/settings.php (or sites/YOUR_SITE/settings.php) and add a line like this:
ini_set('mysql.default_socket', '/var/run/mysql/mysql.sock');

Or if you are using the MySQLi driver then try:
Open your sites/default/settings.php (or sites/YOUR_SITE/settings.php) and add a line like this:
ini_set('mysqli.default_socket', '/var/run/mysql/mysql.sock');


Change your database server in your settings.php file from localhost to 127.0.0.1
(356 vote(s))
Helpful
Not helpful