Ich benutze ubuntu 16.04.
PHP Version 7.0.4-7ubuntu2
.Apache/2.4.18 (Ubuntu)
.PHP extension: mysqli
(in phpmyadmin Written).
Ich habe ein Upgrade meines Ubuntu von 15.10 to 16.04
erhalten und habe diesen Fehler:
Mein Projekt wird korrekt auf meinem Server ausgeführt, kann jedoch nicht in meinem Betriebssystem ausgeführt werden:
Database Exception – yii\db\Exception
SQLSTATE[HY000] [2002] No such file or directory
↵
Caused by: PDOException
SQLSTATE[HY000] [2002] No such file or directory
in /var/www/html/iicitySite/vendor/yiisoft/yii2/db/Connection.php at line 579
Ändern Sie "localhost" als "Host" auf "127.0.0.1"
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:Host=127.0.0.1;dbname=abc',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
Für MAMP-Anwender ist die Lösung
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:Host=localhost;port=8889;dbname=mydbname;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock',
'username' => 'myuser',
'password' => 'mypassword',
'charset' => 'utf8',
],
],
wenn Sie mamp verwenden, verwenden Sie nicht den Befehl "php" in MAC OS, sondern "php" in mamp, z. B. /Applications/MAMP/bin/php/php5.6.30/bin/php yii migrate
.
Ich verwende die MAMP-Umgebung und arbeite gut mit den beiden oben genannten Lösungen
localhost
in 127.0.0.1
ändernlocalhost:3306
)Hoffe, diese Antwort wird dir helfen:
Ändern Sie den Hostnamen von localhost in 127.0.0.1
Dies ist im Backend\common\config\main-local.php
Jetzt führen Sie php yii migrate aus.
Hoffe, es wird erfolgreich die Tabellen in der Datenbank erstellen
Ich hatte das gleiche Problem. Das Ändern von localhost
hat mein Problem nicht gelöst. Fügen Sie stattdessen Ihren Db-Port folgendermaßen hinzu:
'dsn'=>'mysql:Host=localhost:3307;dbname=geep'