我在使用 php yii migrate 命令时出错?
I have error when I used php yii migrate command?
我正在尝试在我的数据库中创建新的迁移,但是在写入 php yii migrate in toggle terminal
之后命令中发生了这个错误
Abdul-fattahs-MacBook-Pro:cust abdul-fattah$ php yii migrate
Yii Migration Tool (based on Yii v2.0.36)
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away'
in /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php:637
Stack trace:
#0 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php(1025): yii\db\Connection->open()
#1 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php(1012): yii\db\Connection->getMasterPdo()
#2 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(255): yii\db\Connection->getSlavePdo()
#3 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(1154): yii\db\Command->prepare(true)
#4 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(401): yii\db\Command->queryInternal('fetchAll', NULL)
#5 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/mysql/Schema.php(319): yii\db\Command->queryAll()
#6 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/mysql/Schema.php(125): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Schema.php(757): yii\db\mysql\Schema->loadTableSchema('migration')
#8 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Schema.php(193): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/MigrateController.php(211): yii\db\Schema->getTableSchema('{{%migration}}', true)
#10 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(877): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#11 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(169): yii\console\controllers\BaseMigrateController->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#15 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Controller.php(181): yii\base\Controller->runAction('', Array)
#16 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#17 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#18 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#19 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 /Applications/MAMP/htdocs/cust/yii(20): yii\base\Application->run()
#21 {main}
这是我在 config/db.php 中的代码,我无法解决我的问题......
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=cust',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
];
这解决了我的问题 我添加了 port:8889
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost:8889;dbname=cust',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
];
我正在尝试在我的数据库中创建新的迁移,但是在写入 php yii migrate in toggle terminal
之后命令中发生了这个错误Abdul-fattahs-MacBook-Pro:cust abdul-fattah$ php yii migrate
Yii Migration Tool (based on Yii v2.0.36)
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away'
in /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php:637
Stack trace:
#0 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php(1025): yii\db\Connection->open()
#1 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Connection.php(1012): yii\db\Connection->getMasterPdo()
#2 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(255): yii\db\Connection->getSlavePdo()
#3 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(1154): yii\db\Command->prepare(true)
#4 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Command.php(401): yii\db\Command->queryInternal('fetchAll', NULL)
#5 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/mysql/Schema.php(319): yii\db\Command->queryAll()
#6 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/mysql/Schema.php(125): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Schema.php(757): yii\db\mysql\Schema->loadTableSchema('migration')
#8 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/db/Schema.php(193): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/MigrateController.php(211): yii\db\Schema->getTableSchema('{{%migration}}', true)
#10 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(877): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#11 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(169): yii\console\controllers\BaseMigrateController->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#15 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Controller.php(181): yii\base\Controller->runAction('', Array)
#16 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#17 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#18 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#19 /Applications/MAMP/htdocs/cust/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 /Applications/MAMP/htdocs/cust/yii(20): yii\base\Application->run()
#21 {main}
这是我在 config/db.php 中的代码,我无法解决我的问题......
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=cust',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
];
这解决了我的问题 我添加了 port:8889
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost:8889;dbname=cust',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
];