Hi.

This is the first time i write in the forum.
After searching and searching i still have not found a solution to my problem.
For a number of months i have been working in my own drupal website. It is like a hobby for me. I have a local Drupal installation using wampserver.

The question is that i made a Windows system restore and since then i don't have access to my Drupal site.
When i put "localhost/drupal7" in the browser's address bar, it shows me the following result: "PDOException: in lock_may_be_available() (line 167 of C:\wamp\www\drupal7\includes\lock.inc).".

Furthermore, when i try to access to Phpmyadmin (i write "root" as username and i leave empty the password, as i did when everything worked fine) it gets me: #2002 cannot log in to the mysql server phpmyadmin.

I have almost no technical knowledge.

Can anyone help me?

I would be very grateful. Thanks.

Comments

John_B’s picture

are you sure mysql is running? has your site got just too big for the resources allocated to mysql in the configuration?

I almost did not answer, because although I am a Windows user, running Drupal on Windows is an absolute pain IMHO. The easiest way is probably to use Acquia Dev Desktop. Better still, get hold of an old laptop and install Linux. Or use a Linux virtual machine on your Windows PC if it has a at least 4MB RAM. I like Drupalpro as a VM (thought it is due for a refresh).

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

Marelmel’s picture

I'm going to take account of what you say.
Finally, I couldn't figure out what caused the problem.
I erased everything and i am doing an other website.

Thank you for your reply.

vjsutar’s picture

In my case mysql was not working.

j-light’s picture

I had the same problem and got here. As John_B suggested, the "problem" was MySQL was down. Went to the mysql_error.log and found the reason. MySQL was not shutdown normally and some innodb files were corrupted. The second attempt to restart the server was succesful and, after the automatic recovery proces, I finally could access the site.

I can't help any more Marelmel, but maybe some files were completely corrupted and couldn't be recovered or purged.

dalegrebey’s picture

I am having this error as well: PDOException: in lock_may_be_available()

...MySQL is running just fine however. For example, I am able to login via phpmyadmin and look at all the database tables, columns, rows, etc.

Yet I am still receiving this error. Any other ideas?

This is the full error:

PDOException: in lock_may_be_available() (line 167 of C:\wamp\www\diligentconsulting\includes\lock.inc).

Thx,
Dale

dalegrebey’s picture

Also manually "emptied" all of the cache files via the database.

John_B’s picture

It happens for several reasons. Diagnosis depends on whether the site worked on that server without you changing something or whether you just moved the site to the server. It can be because mysql is not set up to accept enough connections, or the user you are connecting with has SELECT permissions on mysql but not DELETE or UPDATE etc.

It is difficult to diagnose remotely. One person asking for help on these threads spent a couple of days saying he had entered the correct user name and password in settings.php, and this could not be a problem, and eventually found a mistake! That happens to us all sometimes.

Also check you are not trying to work with a very large database. The size of the ibdata file is something to watch.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

sanjeeve’s picture

we had the same issue and found out that the root cause is low file system space on the database server.
PDOException: SQLSTATE[08004] [1040] Too many connections in lock_may_be_available() (line 167 of /var/www/vhosts/oursite.com/docroot/includes/lock.inc).

sanjeeve’s picture

You could check the below directories if there any large files and remove them if not needed (i.e backups, migrated files etc.,)

/var
/var/www
/var/lib
/var/lib/mysql
/usr
/lib
/lib/modules
/var/cache
/var/cache/apt
/var/lib/mysqlbackup
/var/lib/mysqlbackup/default

If you are running your server on NFS Vm then check the below directories..
/var/www/nfsshare
/var/www/nfsshare/private
/var/www/nfsshare/private/files/resource
/var/www/nfsshare/private/temp
/var/www/nfsshare/private/files
/var/www/nfsshare/private/files/backup_migrate
/var/www/nfsshare/private/files/backup_migrate/scheduled

gebiss’s picture

It's worth checking that the host settings in sites/default/settings.php matches the one from the User in the database. If they don't match you will receive this error message

PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61) in lock_may_be_available() (line 167 of /htdocs/yoursite/includes/lock.inc).

koentimmers’s picture

Same here. I got this error while the connection (sites/default/settings.php) contained some errors (wrong password).

bonzored’s picture

Indeed, I had 2 different passwords. I had secured mysql and blocked root but failed to change the password on drupal.

Dr_Developer’s picture

It is caused by database connection error.
Maybe the username ,or database name or password is wrong in settings.php

MMORPG’s picture

You can delete file to check if it work

dirckdigler’s picture

I had the same issue and after following all their contributions. I found the solution 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). It works for me.

jerrycole11’s picture

PDOException: in lock_may_be_available() (line 167 of C:\wamp\www\car_rental_system\includes\lock.inc).

jerrycole11’s picture

Please let someone help me via teamvierwer on how to set this issue up. I am just a beginner.
Thanks.

John_B’s picture

Realistically it is not likely someone will get on teamviewer to offer unpaid support. Support via the forums is offered because it can help everyone, and some of us who offer that help depend on being paid for Drupal support in order to make a living.

I looked at your issue twice, and wondered why you are struggling with WAMP when it is so easy to run a development site on Windows using Acquia Dev Desktop.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

Alireza.Tabatabaeian’s picture

This error happend to me when my laptop went out of battery at the very last steps of installing drupal, my problem solved by emptying the semaphore table.

pleclerc’s picture

$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'xxxxx',
'username' => 'xxxxxx',
'password' => 'xxxxx',
'host' => 'localhost',
'port' => '3307',
'driver' => 'mysql',
'prefix' => 'pr_',
),
),
);

I had to add the specific mysql port of my localhost configuration. On Windows10. After moving D7 server to localhost.
Hope it's help.

rahulbaisanemca’s picture

I am using ubuntu 16.04,

$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'db_name',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'port' => '3303',
'driver' => 'mysql',
'prefix' => '',
),
),
);

I have added,
port number and my issue resolved.

Thanks,
Rahul.

fishfree’s picture

My problem is due to MySQL 5.7 does not allow root user to access a database from client app. After switching to a normal user, problem solved.

no74h’s picture

Same here; problem with root access, after creating a new user and grant all necessary privileges and updated settings.php everything is good.

robert kipkemoi’s picture

Hi,

After searching KRA HUB I am not finding out what i want because it is giving me an error -PDOException: SQLSTATE[HY000] [1129] Host 'krahub.kra.go.ke' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in lock_may_be_available() (line 167 of /srv/www/htdocs/includes/lock.inc).

Graham Leach’s picture

Hello,

For me, it was an incomplete/crashed restore that caused this issue on a brand new provisioned Ubuntu Server 20.04.  For some reason, the MySQL server "went away" during my restore, stopping just before the restoration of the semaphore table.  Needless to say, the site load crashed hard as a consequence, giving this error.

To get the database to restore fully, I had to enter the mysql environment and use the source command. 

Trying to restore the database from the command line was just crashing the mysql server.

g.

----