XAMPP or MAMP – Can’t connect to mysql

You’ll need to update your DB config file…

What worked for me was adding this:

'mysql' => [
 'driver' => 'mysql',
 'host' => env('DB_HOST', 'localhost'),
 'database' => env('DB_DATABASE', 'db_name'),
 'username' => env('DB_USERNAME', 'db_user'),
 'password' => env('DB_PASSWORD', 'db_password'),
 'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',
 'charset' => 'utf8',
 'collation' => 'utf8_unicode_ci',
 'prefix' => '',
 'strict' => false,
 'options' => [
 #PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => 16777216
 PDO::MYSQL_ATTR_LOCAL_INFILE => true
 ]
],

Here’s one other solution:

I was getting some similar error and ended up here. I am using OSX 10.9.5. This solved my problems (hope it helps someone).

1) sudo mkdir /var/mysql
2) sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

More informations: http://glidingphenomena.blogspot.com.br/2010/03/fixing-warning-mysqlconnect-cant.html

Thanks!

NOTE: Replace /var/mysql/mysql.sock with the path to your actual mysql.sock file (w XAMPP, it would be /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock)

Racker Hacker » MySQL: Errcode: 24 when using LOCK TABLES

Racker Hacker » MySQL: Errcode: 24 when using LOCK TABLES

There’s two ways to fix the problem. First, if you find that you only hit the limit during mysqldumps and never during normal database operation, just add --single-transaction to your mysqldump command line options. This will cause mysql to keep only one table open at a time.

However, if this happens while backups aren’t running, you may want to increase the open_files_limit in your MySQL configuration file. By default, the variable is set to 1,024 open files.

For further reading:
5.2.3. System Variables
7.13. mysqldump – A Database Backup Program