Is the MySQL server on the same EC2 instance as your project? If that's the case you can just use "localhost" as the host.
The MySQL server is on the same EC2 instance as my project. I am using the root user (root@elastic-ip). But when I'm running php artisan migrate, I am getting the same error:
[PDOException]
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '54.186.151.12' (11
1)
migrate [--bench[="..."]] [--database[="..."]] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]
Do you have a different environments configured? Like one for dev and one for prod?
php artisan migrate --env=production
Now after granting all access to root@% in the MySQL server, I'm getting this error:
[PDOException]
SQLSTATE[HY000] [1130] Host '...' is not allowed to connect to this MySQL server
Unfortunately, when it comes to the host name, MySQL distinguishes between localhost
and 127.0.0.1
. What's more, if you grant access to "%", the server still doesn't allow access via Unix domain sockets (rather than TCP). So you need to explicitly grant access to user@localhost as well as to user@%. See this answer on Stack Overflow: http://stackoverflow.com/a/15707789/239678
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community