简体   繁体   English

EC2 AWS上Laravel 4 php artisan migration命令的PDO异常

[英]PDO Exception with Laravel 4 php artisan migrate command on EC2 AWS

I have an ubuntu 12.04 instance on EC2 in AWS and a Laravel 4 Project uploaded there. 我在AWS的EC2上有一个ubuntu 12.04实例,并在那里上传了Laravel 4项目。 I am trying to run php artisan migrate, but for some reason I cannot connect to my mysql server through the command. 我正在尝试运行php artisan migration,但是由于某些原因,我无法通过命令连接到我的mysql服务器。 I am able to get into the MySql DB on SQL Pro just find using SSH (using the elastic ip as host). 我能够进入SQL Pro上的MySql数据库,只是找到使用SSH(使用弹性IP作为主机)。 I also SSH into the server using Elastic IP. 我还使用弹性IP通过SSH进入服务器。

I get this error when I run php artisan migrate: 当我运行php artisan migration时出现此错误:

[PDOException]                                                               
  SQLSTATE[HY000] [2003] Can't connect to MySQL server on '**.***.***.**' (11  
  1)                                                                           



migrate [--bench[="..."]] [--database[="..."]] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

Where the starts represent my "elastic IP", which is the host I use to connect to mySQL in SQL Pro. 开头代表我的“弹性IP”,这是我用来连接到SQL Pro中的mySQL的主机。

In my database.php config file, I am connecting using: 在我的database.php配置文件中,我使用以下方法进行连接:

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => '*ELASTIC IP*',
            'database'  => 'dbname',
            'username'  => '****',
            'password'  => '*******',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

I have installed php5, apache2, mcrypt, and php5-mysql on this server. 我已经在此服务器上安装了php5,apache2,mcrypt和php5-mysql。 How do I solve this issue? 我该如何解决这个问题? Thank you. 谢谢。

Sounds like you are not necessarily allowing your 'user' into the database. 听起来您不一定允许您的“用户”进入数据库。

In MySQL the 'user' is a combination of 'username'@'hostname' . 在MySQL中,“用户”是'username'@'hostname' It could be that you are just allowing your username for a particular host which could be localhost or 127.0.0.1 . 可能是您只允许将特定主机的username用作localhost127.0.0.1 To see if this is the problem you can create a user with the hostname wildcard % . 要查看是否存在此问题,可以创建一个主机名通配符%的用户。 Also, by allowing that user to all databases. 同样,通过允许该用户访问所有数据库。 From the mysql> command line like this: mysql>命令行像这样:

CREATE USER '<username>'@'%' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* TO '<username>'@'%';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM