Error establishing a database connection when Everything is Right![Wordpress]

Database name, user and password were right in my wp-config.php file, but still I got 'Error establishing a database connection' even though the Wordpress blog worked fine before. This may help you if you were puzzled like me by this error & couldn't figure out the solution. For me the problem was in mysql tables. Checking them in phpMyAdmin I found one of them showing 'In use' in the 'Type case', this can be fix by selecting the table (or tables) & choosing 'Repair table'. This may solve the problem for you, but in my case the repair task failed because phpMyAdmin (or Mysql?) couldn't write in the affected tables. That's probably the cause of the whole problem. phpMyAdmin tells you what went wrong in the repairing process & shows you path(s) to the file(s) it couldn't overwrite. To fix this you need to change the ownership of the affected tables. For that you may need to use SSH to find the table(s) file(s) on your