Migration Error

Hi,

I am trying to run a migration which have been created successfully. I am have a basic application running on XAMPP. (php yii migrate up) and I get the following error in the terminal:


Yii Migration Tool (based on Yii v2.0.12-dev)


Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] No such file or directory'


in /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Connection.php:568


Stack trace:

#0 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Connection.php(912): yii\db\Connection->open()

#1 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Connection.php(899): yii\db\Connection->getMasterPdo()

#2 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Command.php(219): yii\db\Connection->getSlavePdo()

#3 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Command.php(896): yii\db\Command->prepare(true)

#4 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)

#5 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/mysql/Schema.php(199): yii\db\Command->queryAll()

#6 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/mysql/Schema.php(98): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))

#7 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/db/Schema.php(152): yii\db\mysql\Schema->loadTableSchema('migration')

#8 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/controllers/MigrateController.php(199): yii\db\Schema->getTableSchema('{{%migration}}', true)

#9 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(774): yii\console\controllers\MigrateController->getMigrationHistory(NULL)

#10 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(138): yii\console\controllers\BaseMigrateController->getNewMigrations()

#11 [internal function]: yii\console\controllers\BaseMigrateController->actionUp('up')

#12 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

#13 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)

#14 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/Controller.php(128): yii\base\Controller->runAction('', Array)

#15 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/base/Module.php(523): yii\console\Controller->runAction('', Array)

#16 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)

#17 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)

#18 /Applications/XAMPP/xamppfiles/htdocs/myapp/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))

#19 /Applications/XAMPP/xamppfiles/htdocs/myapp/yii(20): yii\base\Application->run()

#20 {main}



My db.php reads:


<?php


return [

    'class' => 'yii\db\Connection',

    'dsn' => 'mysql:host=localhost;dbname=mydb;',

    'emulatePrepare'=>true,

    'username' => 'myusername',

    'password' => 'mypassword',

    'charset' => 'utf8',

];

Any ideas why that this is not working? I tried adding port=… and also Socket=pathtosocket to my connection string.

In requirements php I have a Warning about PostgreSQL but I am using phpmyadmin

Thanks

That’s coming from MySQL.

Thanks. This fixed it (no idea how - something to do with creating a symbolic link to my sql socket):


sudo mkdir /var/mysql

cd /var/mysql

sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock