本文介绍了SQLSTATE HY000 2002运行烘焙命令时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在运行bake命令时遇到问题。我认为它与mysql有关,但在Stackoverflow上找不到此错误的任何解决方案。
这是我的 app.php
:
I have problem running the bake commands. i think it is related to mysql but i didn't find any solution to this error on Stackoverflow.This is my 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,
请帮助,我得到的错误是:
Please help, the error i get, is:
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', '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中的这一行以使其起作用:
Problem solved!!The only thing i should add is this line in .bash_profile to make it work:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
这篇关于SQLSTATE HY000 2002运行烘焙命令时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!