PDOException: SQLSTATE[HY000] [1045]

If you getting the below error after moving the Live site to localhost .You may get the same error whether you are using Xampp or Wamp server on your local machine.

PDOException: SQLSTATE[HY000] [1045] Access denied for user 'xxx'@'localhost' (using password: YES) in lock_may_be_available() (line 167 of C:\xampp\htdocs\xxx\includes\lock.inc).

The error is due to problem with database settings.
Goto xxx\sites\default\ on your localhost. Open the file settings.php .Goto the below code.see the settings

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'naiwik',
      'username' => 'nawik',
      'password' => 'Password',
      'host' => 'localhost',

      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Now on your localhost open phpmyadmin i.e. locahost/phpmyadmin

1) Goto to database you have created & imported .mysql file from the live site.

2) Goto Privileges

3) Create a new User by Clicking on "Add user"

4) Give the Username , Host , Password & grant all privileges to the user.

5) Update the same details in the Settings.php file in \sites\default\  & save  it

5) Now the site should work

The above steps will solve PDOException: SQLSTATE[HY000] [1045] error on Both Xampp or Wamp