-1

I updated my Mamp Pro application to 6.2 and everything works well. My Symfony is running with the database, so everything is fine.

in the env file I am using this setting:

DATABASE_URL=mysql://root:root@localhost/mypage

Now the problem is, that in the console I want to make a migration, and this is not working anymore

php bin/console doctrine:migrations:diff

I get the error

An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory

peace_love
  • 6,229
  • 11
  • 69
  • 157
  • sometime removing the cache may help `sudo rm -rf var/cache/*` from projectDir – john Smith Dec 21 '20 at 11:06
  • 1
    Does this answer your question? [MySQL connection not working: 2002 No such file or directory](https://stackoverflow.com/questions/1676688/mysql-connection-not-working-2002-no-such-file-or-directory) – yivi Dec 21 '20 at 11:41
  • @yivi no unfortunately not, I already tried the solutions on the page, but they do not work for me. I am totally desperate. I do not understand – peace_love Dec 21 '20 at 11:47
  • @johnSmith tested it, but it does not help – peace_love Dec 21 '20 at 11:47
  • Kinda stupid question, but are you sure your mysql server is running? Can you connect via cli tool (`mysql -uroot -proot mypage`)? – dbrumann Dec 21 '20 at 12:11
  • Please share more details - if Symfony is running fine, but generating migrations does not work, what's the difference in configuration? – Nico Haase Dec 21 '20 at 12:56
  • @NicoHaase Where can I check this difference. I made the sql settings in the .env file – peace_love Dec 22 '20 at 11:47
  • @dbrumann the mysql server is running, my Symfony application is working, everything is fine, I can login and everything. The only thing is, that I cannot make any migrations in the console – peace_love Dec 22 '20 at 12:10

1 Answers1

0

After a long research I finally found the solution:

The php version of the terminal did not match the php version of MAMP. I had to use the mamp php version instead of the default osx php version.

1. Locate your osx php version with:

which php

The result should be:

/usr/local/bin/php

2. Backup (move) your original php binary:

sudo mv /usr/local/bin/php /usr/local/bin/php.bak

3. Create the symlink:

sudo ln -s /Applications/MAMP/bin/php/php7.4.12/bin/php /usr/local/bin/php

4. Run your new php version:

php -v

peace_love
  • 6,229
  • 11
  • 69
  • 157