Answer the question
In order to leave comments, you need to log in
yii migrate does not work, gives an error SQLSTATE[HY000] [2002] how to overcome?
I am creating a new project in yii2 advanced. I open the console of the site directory, I did php init and then I write: php yii migrate
what gives me an error:
Yii Migration Tool (based on Yii v2.0.12)
Error: SQLSTATE[HY000] [2002] No such file or directory
127.0.0.1
Yii Migration Tool (based on Yii v2.0.12)
Error: SQLSTATE[HY000] [2002] Connection refused
localhost
with 127.0.0.1
and writing to the console sudo killall mysql.
does not help. Reinstalled MAMP (latest version), reinstalled MAC OS (sierra). sudo php yii migrate
No log handling enabled - using stderr logging
Created directory: /var/db/net-snmp
Created directory: /var/db/net-snmp/mib_indexes
Yii Migration Tool (based on Yii v2.0.12)
Error: SQLSTATE[HY000] [2002] Connection refused
Answer the question
In order to leave comments, you need to log in
Solution for MacOS 10.13 and MAMP/XAMPP (just change socket path).
You need to create a symlink to the MySQL socket so that PHP can see it. This solves the problem.
To do this, write in the console:
sudo mkdir /var/mysql
cd /var/mysql && sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question