First thing that caught my eyes, shouldn't DB_HOST be 127.0.0.1 ?
SQLSTATE[HY000] [2002] No such file or directory (SQL: select count(*)
Hi i'm new to laravel and have been working on a micro project to learn more about the framework (bloody awesome framework abselutly loving it) but i'm having issues with the database settings and environments.
Im getting this error in localhost (not pushed to heroku yet):
SQLSTATE[HY000] [2002] No such file or directory (SQL: select count(*) as aggregate from users where email = [email protected])
Im using heroku on my production env and localhost on MAMP for my local env
My database.php file is:
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$host = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$database = substr($url["path"], 1);
'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', $host),
'database' => env('DB_HOST', $database),
'username' => env('DB_USERNAME', $username),
'password' => env('DB_PASSWORD', $password),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'unix_socket' => env('UNIX_SOCKET',
'/Applications/MAMP/tmp/mysql/mysql.sock'),
],
and my .env file:
APP_ENV=local
APP_KEY=base64:mykey=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:8888
DB_CONNECTION=mysql
DB_HOST=129.0.0.1
DB_PORT=8889
DB_DATABASE=cw-site
DB_USERNAME=root
DB_PASSWORD=root
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
This is happening when i try to register a new user.
Any help or ideas on where to look would be grateful.
Many thanks Chris
Quick update i tried "php artisan config:clear" which hasnt worked but i do get these errors:
PHP Notice: Undefined index: host in /Users/myuser/Desktop/Apps/master/config/database.php on line 4
Notice: Undefined index: host in /Users/myuser/Desktop/Apps/master/config/database.php on line 4
PHP Notice: Undefined index: user in /Users/myuser/Desktop/Apps/master/config/database.php on line 5
Notice: Undefined index: user in /Users/myuser/Desktop/Apps/master/config/database.php on line 5
PHP Notice: Undefined index: pass in /Users/myuser/Desktop/Apps/master/config/database.php on line 6
Notice: Undefined index: pass in /Users/myuser/Desktop/Apps/master/config/database.php on line 6
The lines are these:
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$host = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$database = substr($url["path"], 1);
Ok so ive got it working! It was to do with the the .env file! I had this in it
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
I removed this and put it in the config/database.php
'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'),
Please or to participate in this conversation.