1

I'm hoping someone can point me to a fix. My drupal 7 app was running fine locally this a.m. while I was testing a way to insert a row using mysql tools for a non-Drupal function. My environment is Apache running virtual host on php 5.4.34 on a Ubuntu VM.

After not getting satisfaction using the mysql functions, I started a simple PDO function using Drupal's database settings from the settings.php file. I was able to insert a row successfully but when I returned to the local site I got this error after a long time:

drupal_log_error(Array ([%type] => PDOException,[!message] => SQLSTATE[HY000] [2002] Connection timed out,[%function] => lock_may_be_available(),[%file] => /media/psf/Home/apps/habitatnashville/includes/lock.inc,[%line] => 167, etc

[%type] => PDOException
    [!message] => SQLSTATE[HY000] [2002] Connection timed out
    [%function] => lock_may_be_available()
    [%file] => /media/psf/Home/apps/habitatnashville/includes/lock.inc
    [%line] => 167
    [severity_level] => 3

I've looked here and on Drupal's site. Because it's a connection error the likely suspects are that I've munged the credentials somehow.

When something like this happened months ago, I did a service mysql restart, did that again a few minutes ago, rebooted the ubuntu VM and rebooted entire computer to shake that lock.

I've removed that test file with the PDO just in case. Here's the output of my drush status:

Drupal version                  :  7.27                                        
 Site URI                        :  http://default                              
 Database driver                 :  mysql                                       
 Database username               :  admin                                
 Database name                   :  my_db                             
 Database                        :  Connected                                   
 Drupal bootstrap                :  Successful                                  
 Drupal user                     :  Anonymous                                   
 Default theme                   :  My_theme                                    
 Administration theme            :  rubik                                       
 PHP executable                  :  /home/sam/.phpbrew/php/php-5.4.34/bin/php   
 PHP configuration               :  /home/sam/.phpbrew/php/php-5.4.34/etc/php.i 
                                    ni                                          
 PHP OS                          :  Linux                                       
 Drush version                   :  6.2.0 

My database is running as "service mysql status" => mysql: start/running, process 1291. What else could be affecting this?

5
  • "Connection timed out". My guess is there could be some DNS issues. Checkout slides 64-72 for some ideas on things to try.
    – mikeytown2
    Commented Apr 14, 2015 at 21:05
  • Yes, that makes sense. I've changed the reference to the IP addy of the db server temporarily, but it doesn't seem to be the cause, at least in this case. The slides were very helpful for related things I need so that's a bonus.
    – sam452
    Commented Apr 16, 2015 at 16:50
  • Is it the port number?
    – mikeytown2
    Commented Apr 16, 2015 at 19:45
  • I don't think so as it was working earlier in the day. My "fix" to get past it was to increase memory in PHP, Drupal from 128m to 150m. If you'd like, pls form it into an answer.
    – sam452
    Commented Apr 17, 2015 at 13:53
  • I noticed you've suggested to increase the memory, which I've written as last point in my answer. Commented Oct 13, 2018 at 9:55

1 Answer 1

0

There could be multiple reasons/thoughts:

  1. Are you sure mysql is running?
  2. Has your site got just too big for the resources allocated to mysql in the configuration?
  3. Did you manually "emptied" all of the cache files via the database?
  4. Low file system space on the database server
  5. If you just moved the site to the other server and mysql is not set up to accept enough connections.
  6. The user you are connecting with has SELECT permissions on mysql but not DELETE or UPDATE etc.
  7. The host settings in sites/default/settings.php doesn't matche the one from the User in the database
  8. MySQL 5.7 does not allow root user to access a database from client app. After switching to a normal user, it solves.
  9. Sometimes tuning xampp like on php.ini (memory_limit=256M) and my.ini (max_allowed_packet = 32M) and disable devel by drush (drush dis -y devel) also works. ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.