PHP Artisan使用MAMP和Unix套接字迁移 [英] PHP Artisan Migrate with MAMP and Unix Socket

查看:73
本文介绍了PHP Artisan使用MAMP和Unix套接字迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初是在Laravel 4.2中开发我的应用程序,但此后决定将其移至5.0版本,以便它涵盖5.0超过4.2的更多更改和优势.

I was developing my application originally in Laravel 4.2 but have since decided to move it to the 5.0 version so that it covers a lot more changes and strengths that 5.0 has over 4.2.

我正在尝试运行我的迁移,但是出现错误:

I am trying to run my migratiosn however I am getting the error:

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

我调查了一下,发现它是怎么回事,因为我正在为服务器运行MAMP,而不是无所事事和宅基地.我并没有敲定这两个用途,但在这一点上,我对MAMP感到更自在,直到它使我失望为止.我知道它的MAMP的原因是因为需要声明要使用的unix套接字值.

I looked into this and noticed how it is because I'm running MAMP for my server instead of vagrant and homestead. I'm not knocking the uses of those two but I at this point feel more comfortable with MAMP until it fails me. The reason I know its MAMP is because of needing to declare the unix socket value to be used.

现在在我的4.2版本的应用程序中,我具有以下内容:

Now on my 4.2 version of my application I have the following:

'mysql' => array(
    'driver'    => 'mysql',
    'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
    'host'      => getenv('DB_HOST'),
    ...
),

在我的Laravel 5.0版本中,我正在使用.env文件作为我的环境变量,但不确定我该怎么做,以便它知道使用unix套接字值.

With my Laravel 5.0 version I am making use of the .env file for my Environment variables and not sure how I need to do this so that it knows to use the unix socket value.

有人可以帮助我了解如何将其应用到新版本中,或者以更好的方式将其添加到设置中,从而不必这样做吗?

Cans someone clue me into how I should adopt this into the new version or a better way to add it into the settings so that I don't have to do that?

推荐答案

尝试一下:

'mysql' => array(
'driver'    => 'mysql',
'unix_socket'   => getenv('UNIX_SOCKET'),
'host'      => getenv('DB_HOST'),
...
),

在.env中添加

UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

这篇关于PHP Artisan使用MAMP和Unix套接字迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆