I’ve installed MAMP on my Mac to do some changes to my blog. I tried to set the WordPress wp-config.php file to connect to localhost:8889, but got an error that It could not connect to the database. After replacing localhost:8889 to 127.0.0.1:8889 it works. My quick guess is that permissions for the root user is set to allow connections 127.0.0.1, but not localhost. Anyway, it works now.
My wp-config.php file looks like this:
define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', 'root'); /** MySQL hostname */ define('DB_HOST', '127.0.0.1:8889');
Janus says
Thanks! Just the solution to my problem too 🙂
Gustavo says
I tried doing that and didn’t work. Any thoughts as to why?
Gustavo says
Actually it did establish the connection to the database but it now says “WPMU only works without the port number in the URL.”
Komunitas Blogger Indonesia says
thankz alot.. simple solution but work…
i use windows 7 and i change localhost became 127.0.0.1 and everything work..
Tim Tom says
Solved. Thanks you a lot!
http://weelii.com/how-to-fix-error-establishing-a-database-connection/
Michelle says
Thanks. I just solved my problem.
yanno says
search a lot of solutions for this problem and your’s the first that really helped me! Hero!
Jack Zimmermann says
Much obliged!
Margarret says
Thanks I spent days on this problem this is the only solution that worked.
ghusoon says
Thank you very much, Its take all day.Its work after I change the host name.