Homebrew PHP and MAMP MySQL socket fun
Joe • April 20, 2015
laravel linuxWhile setting up a new project in MAMP for my day job I ran into an odd problem trying to run artisan migrations.
Running this command:
php artisan migrate:refresh -- env=local
Threw this error:
{"error":{"type":"PDOException","message":"SQLSTATE[HY000] [2002] No such file or directory","file":"\/Users\/halo\/PhpstormProjects\/project\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connectors\/Connector.php","line":47}}%
A quick google search came up with this which pointed to:
Short answer: Change "host" in the /app/config/database.php file from "localhost" to "127.0.0.1"
Changing that fixed my issue, but what was the actual cause of the issue?
I installed PHP locally using Homebrew, and MAMP is using it's own versions of PHP and since I was running artisan against my Homebrew version of PHP I needed to point
pdo_mysql.default_socket
to the MySQL socket from MAMP.
Adding
pdo_mysql.default_socket=/Applications/MAMP/tmp/mysql/mysql.sock
to
/usr/local/etc/php/5.6/php.ini
resolved my issue.
Hopefully this helps someone else.
As Seen On
Recent Posts
- PHP to Rust via Copilot
- Compiling Python 3.12 from Source Tarball on Linux
- HTML Form Processing with PHP - php[architect] Magazine August 2014
- The Workshop: Local Dev with Lando - php[architect] Magazine November 2022
- Getting back into the swing of things
- All Posts
Categories
- ansible
- apache
- applesilicon
- aws
- blackwidow
- cakephp
- community
- composer
- conferences
- copilot
- data-storage
- day-job
- devops
- docker
- fpv
- general
- github
- givecamp
- homestead
- jigsaw
- joindin
- keyboard
- laravel
- learning
- linux
- maker
- mamp
- mentoring
- music
- nonprofit
- opensource
- packages
- php
- phparch
- projects
- provisioning
- python
- razer
- rust
- s3
- security
- slimphp
- speaking
- static-sites
- storage
- testing
- tiny-whoop
- today-i-learned
- training
- ubuntu
- vagrant
- version-control
- windows
- writing
- wsl
- wsl2
- zend-zray