SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql1.alwaysdata.com:3306' (2)

妖精的绣舞 提交于 2019-12-05 20:21:47

The port has it's own parameter in the DSN:

'mysql:host=mysql1.alwaysdata.com;port=3306;dbname=xxx'

Alternatively just omit the port, 3306 is the default port.

philipjc

I had this issue while using Laravel with MAMP and Sequal Pro.

Inside the .env file, I set the

DB_HOST = "localhost"
DB_PORT = "3306"

and this worked.

Before, I had

DB_HOST = "localhost:8889"

I kept getting this error because of the failing DNS service due to the time on my Virtualbox being off - it does that after you put your host machine to sleep for example.

Hope this helps someone in a similar situation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!