cakephp-3.0 – 运行bake命令时的SQLSTATE HY000 2002

前端之家收集整理的这篇文章主要介绍了cakephp-3.0 – 运行bake命令时的SQLSTATE HY000 2002前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在运行bake命令时遇到问题.我认为它与 mysql有关,但我没有在Stackoverflow上找到任何解决错误方法.
这是我的app.PHP
'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection','driver' => 'Cake\Database\Driver\MysqL','persistent' => false,'host' => 'localhost',//'port' => 'nonstandard_port_number','username' => 'root','password' => 'root','database' => 'laboiterose','encoding' => 'utf8','timezone' => 'UTC','cacheMetadata' => true,

请帮忙,我得到的错误是:

Exception: sqlSTATE[HY000] [2002] No such file or directory in [/Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Driver/PDODriverTrait.PHP,line 48]
2015-06-19 14:35:48 Error: [PDOException] sqlSTATE[HY000] [2002] No such file or directory
Stack Trace:
0 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Driver/PDODriverTrait.PHP(48): PDO->__construct('MysqL:host=loca...','root',Array)
1 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Driver/MysqL.PHP(89): Cake\Database\Driver\MysqL->_connect('MysqL:host=loca...',Array)
2 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Schema/BaseSchema.PHP(46): Cake\Database\Driver\MysqL->connect()
3 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Dialect/MysqLDialectTrait.PHP(62): Cake\Database\Schema\BaseSchema->__construct(Object(Cake\Database\Driver\MysqL))
4 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Schema/Collection.PHP(52): Cake\Database\Driver\MysqL->schemaDialect()
5 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Schema/CachedCollection.PHP(44): Cake\Database\Schema\Collection->__construct(Object(Cake\Database\Connection))
6 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Database/Connection.PHP(319): Cake\Database\Schema\CachedCollection->__construct(Object(Cake\Database\Connection),true)
7 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/Task/ModelTask.PHP(806): Cake\Database\Connection->schemaCollection()
8 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/Task/ModelTask.PHP(782): Bake\Shell\Task\ModelTask->_getAllTables()
9 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/Task/ModelTask.PHP(186): Bake\Shell\Task\ModelTask->listAll()
10 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/Task/ModelTask.PHP(109): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table))
11 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/Task/ModelTask.PHP(95): Bake\Shell\Task\ModelTask->bake('Users')
12 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/bake/src/Shell/BakeShell.PHP(241): Bake\Shell\Task\ModelTask->main('Users')
13 [internal function]: Bake\Shell\BakeShell->all('users')
14 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Console/Shell.PHP(380): call_user_func_array(Array,Array)
15 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Console/ShellDispatcher.PHP(204): Cake\Console\Shell->runCommand(Array,true)
16 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Console/ShellDispatcher.PHP(175): Cake\Console\ShellDispatcher->_dispatch()
17 /Applications/MAMP/htdocs/my_db/vendor/cakePHP/cakePHP/src/Console/ShellDispatcher.PHP(126): Cake\Console\ShellDispatcher->dispatch()
18 /Applications/MAMP/htdocs/my_db/bin/cake.PHP(33): Cake\Console\ShellDispatcher::run(Array)
19 {main}
问题解决了!!
我应该添加的唯一内容是.bash_profile中的这一行使其工作:
export PATH=/Applications/MAMP/bin/PHP/PHP5.6.10/bin:$PATH

猜你在找的PHP相关文章