SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61) error Laravel 4.1
An error like that means the server itself is not even reachable. Did you start MySQL in MAMP?
Also, how have you started MAMP? With the standard MySQL 3306
port? Or the alternative port MAMP uses for non-admins: 8889
?
I bet your server is running, but is attempting to connect to 3306
so you need to set the port to 8889
. Change your config to be like this; note the addition of the port
param:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '8889',
'database' => 'database',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
EDIT: I just found this question thread that addresses the issue of connecting Laravel to MAMP via port 8889
.
Connecting to remote mysql works in terminal, not via PHP PDO script
I got it working by running a command in the database server :)
setsebool httpd_can_network_connect_db=1
thanks for the replies yycdev
PDOException SQLSTATE[HY000] [2002] Connection timed out on my local computer
For remote access, You should to enable remote access to your MySQL Server.
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Related Topics
Notice: Undefined Index: Http_Referer
Php's Function to List All Objects's Properties and Methods
Phpmailer Error: Smtp -> Error: Failed to Connect to Server
Routes in Codeigniter - Automatically
Call to Undefined Function Password_Hash()
PHP Laravel: No Connection Could Be Made Because the Target MAChine Actively Refused It
How Do We Implement Custom API-Only Authentication in Laravel
How to Join Three Tables in Codeigniter
Laravel Input Facade VS Request Facade
PHP Sort($Array) Returning 1 Instead of Sorted Array
HTML Purifier: Removing an Element Conditionally Based on Its Attributes
In Htaccess, I'D Like to Replace Underscores with Hyphens and Then Redirect the User the New Url
Uncaught Error: Class 'Composerautoloaderinit' Not Found
How to Have Multiple $_Get with the Same Key, Different Values