php artisan migrate 无法迁移数据库

2016-11-20  本文已影响0人  yundGo

Mac下使用php artisan migrate无法迁移数据库,报错如下:

[PDOException]
SQLSTATE[HY000][2002] No such file or directory

在终端查看MySQL 查看sockset的值
show variables like '%sock%'

+---------------+-----------------------------------------+

| Variable_name | Value                                   |

+---------------+-----------------------------------------+

| socket        | /Applications/MAMP/tmp/mysql/mysql.sock |

+---------------+-----------------------------------------+

编辑config下的 ***database.php ***在mysql项里面添加socket值

'unix_socket' =>  '/Applications/MAMP/tmp/mysql/mysql.sock'
'mysql'=> [
  'driver'=>'mysql','host'=> env('DB_HOST', '127.0.0.1'),
  'port'=> env('DB_PORT', '3306'),
  'database'=> env('DB_DATABASE', 'test'),
  'username'=> env('DB_USERNAME', 'root'),
  'password'=> env('DB_PASSWORD', 'root'),
  'charset'=> 'utf8','collation'=> 'utf8_unicode_ci','prefix'=> '',
  'strict'=> false,'engine' => null,
  'unix_socket'=>'/Applications/MAMP/tmp/mysql/mysql.sock'
],
上一篇下一篇

猜你喜欢

热点阅读