I had a similar problem with my mysql/linux installation. The connection to the mysql database failed, because it tried to communicate through a socket. The socket was in
the moodle installation expected it in
How can you find out if you have the same problem.
1. search for my.cnf (Configuration file of mysql)
There is something like
port = 3306
socket = /tmp/mysql.sock
so the mysql offers the socket in /tmp
2. Find out where moodle tries to connect
Go to your moodle base directory and edit the file
search for the follwing lines
$CFG->libdir = "$CFG->dirroot
require_once("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
$db = &ADONewConnection($CFG->dbtype);
after this line add the folliwing command
save the file.
3. use your html browser and load the page that produced the error message again.
The first line will show you the result of the debug. It will show you where Moodle expects the socket. (In my case it was /var/run/mysqld/mysqld.sock)
4. If the two socket location are not the same no database connection will be established.
5 Don't forget to uncomment the added code after you know the location.
If the two locations are different and Moodle is the only application using mysql , you can just edit /etc/my.cnf and change towards the path from moodle. Restart the mysql and everything should work fine.
If the two locations are different and more applications use the database you can use the following quickfix. Just add a symbolic link so the socket is also accessible from the path where moodle expects it.
Hope this helps