2014-12-28 56 views
1

工作我在laravel新手,试图运行php artisan migrate:install,就有了一个错误迁移::安装不laravel

[PDOException]                        
    SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 

我已经修改应用程序/配置/本地/ database.php中和app/config/database.php like -

'fetch' => PDO::FETCH_CLASS, 
     'default' => 'mysql', 
    'connections' => array(

     'mysql' => array(
      'driver' => 'mysql', 
      'host'  => 'localhost', 
      'database' => 'laravel_db', 
      'username' => 'root', 
      'password' => '', 
      'charset' => 'utf8', 
      'collation' => 'utf8_unicode_ci', 
      'prefix' => '', 
     ) 
+2

[可能相关的问题](http://stackoverflow.com/questions/5376427/cant-connect-to-local-mysql-server-through-socket-var-mysql-mysql-sock-38) – Supericy

+0

@Supericy :但实际问题不是这样。我有解决方案。张贴在我的答案。 – iNikkz

回答

2

得到了解决方案。

实际的问题是,我们必须配置路径文件/etc/mysql/my.cnf/opt/lampp/etc/my.cnf

socket  = /var/run/mysqld/mysqld.sock 
1

在config文件夹中打开database.php中,如果您使用laravel 4+版本并在mysql凭据中将localhost更改为127.0.0.1。

,如果你正在使用laravel 5+版本然后编辑ENV文件,并localhost更改为127.0.0.1

这就是我如何解决在我的Ubuntu(开发机)这个问题。

希望它会有所帮助。

+0

亲爱的@ user3284742它解决了我的问题。谢谢。 – Raham