Hi,
i am having difficulty solving an error message:
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
I am seeing this error message when i use XDebug and Eclipse for a local Drupal installation on a Ubuntu 10.04 machine. I am trying to complete a migration from Drupal 5 to Drupal 6.
(I can load the index.php of the Drupal installation in Firefox. however, i can't login with the root password. To solve this i'm using Xdebug/Eclipse.)
i have been trying to fix this for a week. frustration is very high. i can't believe the difficulty of this. I posted about it on another forum but so far no one has replied:
http://ubuntuforums.org/showthread.php?p=10302627#post10302627
i can connect to mysql in the terminal by:
mysql -uroot -p
once i have authenticated, the unix sock file is identified as:
/var/run/mysqld/mysqld.sock
i am not however able to connect this way:
mysqladmin --socket=/var/run/mysqld/mysqld.sock --user=root --password=foobar version
i get:
Access denied for user 'root'@'localhost
I have created (i think) a symbolic link:
cd /tmp/
sudo ln -s /var/run/mysqld/
this worked the first time i did it. (subsequent tries: File exists.)
I have noted that Drupal expects a file named:
/tmp/mysql.sock
while I have:
/var/run/mysqld/mysqld.sock
However, since /tmp/mysql.sock doesn't exist, i can't create a symbolic link between the two files; i.e., can't do this:
sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock
I also have edited my.cnf, php.ini and debian.cnf:
/etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
/etc/mysql/debian.cnf
[client]
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
socket = /var/run/mysqld/mysqld.sock
/etc/php/apache2
mysql.default_socket=/var/run/mysqld/mysqld.sock
(With every change i have restarted Apache.)
Drupal just goes on an ignores the instruction where the sock file is, no matter how many times i ask it to look beyond /tmp/mysql.sock.
Is reinstalling my (otherwise) working installation of MySQL needed? If so, will i have to backup my databases before i reinstall it?
this is a very frustrating problem. all help appreciated. thanks.
Comments
another resource?
hi, i can't seem to get anyone using Ubuntu or Drupal to offer some insight with a reply. does anyone know a place where i can find some assistance? (I'm two weeks into trying to solve this and no one has helped.)
thanks.
suddenly working
i don't know how it happened, but suddenly i can login to the local site. i changed the settings.php and default.settings.php files so that the $db_url variable attempted to use another account besides the root. it didn't work. so, i changed it back to what it was originally, restarted Apache and suddenly, i can login.
this took a couple of weeks, but i'm glad that Drupal finally figured out what was needed. thanks for reading.
can't run mysqld_safe
hi,
my last comment was premature. i can login to my Drupal site. however, i'm still getting a mysqld.sock error when attempting to resolve the index.php file of my local Drupal installation.
I have tried to reinstall mysql. however, after doing so i *still* get the mysqld.sock error.
i found this discussion:
http://ubuntuforums.org/showthread.php?t=111292
this has prompted me to try to run 'mysqld_safe'; i.e.,
cd /usr/bin
mysqld_safe
I get this output:
110117 22:06:46 mysqld_safe Logging to syslog.
110117 22:06:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
rm: cannot remove `/var/run/mysqld/mysqld.sock': Permission denied
rm: cannot remove `/var/lib/mysql/mps-desktop.pid': Permission denied
110117 22:06:49 mysqld_safe mysqld from pid file /var/lib/mysql/mps-desktop.pid ended
the permissions for the mysqld.sock file are:
cd /var/run/mysqld
ls -l yields:
srwxrwxrwx
Can anyone help me repair and/or reinstall my mysqld.sock file? I'm sure hoping i can get some help with this. it has been an exasperating month.
thanks.
can't stop the service either
hi,
i have also tried to stop mysql:
service mysql stop
this produces the fun message:
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.55" (uid=1000 pid=9735 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
i can't seem to reinstall mysql and i can't run a mysqld_safe in an effort to repair/replace my mysqld.sock file. Any help is appreciated. thanks.
found a solution
Hi,
I finally found a solution that works for my local installation of Drupal. I want to share it so that the next person doesn't experience the frustration i went through.
this thread was invaluable:
http://drupal.org/node/7620
i changed my settings file like this:
$db_url = 'mysql://root:password@localhost:port:/var/run/mysqld/mysqld.sock/database_name';
note that contrary to what the poster offered on that thread, i did not URL-encode this string.
In addition, i modified the database.mysql.inc:
function db_connect($url) {
$url = parse_url($url);
...
// Allow for non-standard MySQL port.
if (isset($url['port'])) {
$url['host'] = $url['host'] .':'. $url['port'];
}
/** Added to allow socket file in path; last path element becomes DB name *****/
$p = explode('/', $url['path'] );
$plen = count($p);
if ($plen > 1) {
$url['path'] = '/' . array_pop($p);
$url['host'] = $url['host'] .':'. join('/', $p); }
This technique works, and i am so relieved that Drupal can now connect to the MySQL database.
Your try of setting the
Your try of setting the mysql.default_socket might have failed because drupal 6 seems to use mysqli by default. In my settings.php I have
$db_url = 'mysqli://...And thus, one has to set mysqli.default_socket and not mysql.default_socket. You can do that either in settings.php with
ini_set('mysqli.default_socket', '/var/lib/mysql/mysqldrupal/mysql.sock');or in your httpd.conf/apache.conf by
php_admin_value mysqli.default_socket /var/lib/mysql/mysqldrupal/mysql.socke.g. inside the directory setting for your drupal installation.Works for me
This works for me. I have added the line
ini_set('mysqli.default_socket', '/tmp/mysql5.sock');Thanks for the comment.