I'm following a book "Agile Web Application Development with Yii" and I am setting up a database connection to the Yii application through an application component.
I followed the books instructions and said the mysql db host is 127.0.0.1. I ran a test and it failed to connect.
Then I changed the host to "localhost" and it works.
Does anyone know why this is the case?
Check the file name host at this location
C:\WINDOWS\system32\drivers\etc
Check the default value of localhost in the host file, by default it should be 127.0.0.1
if not, change it to 127.0.0.1
. Now try to access your wamp server by using 127.0.0.1 on any web browser.
Please refer this problem: Mysql localhost != 127.0.0.1?
Socket is used when localhost
, while tcp/ip is used when 127.0.0.1
.