SQLSTATE [HY000] [2005]未知的MySQL服务器主机'mysql1.alwaysdata.com:3306'(2) [英] SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql1.alwaysdata.com:3306' (2)

查看:247
本文介绍了SQLSTATE [HY000] [2005]未知的MySQL服务器主机'mysql1.alwaysdata.com:3306'(2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试访问项目的某些网页时出现此错误:SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql1.alwaysdata.com:3306' (2)

I have this error when i try to access to some web pages of my project:SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql1.alwaysdata.com:3306' (2)

alwaysdata 是我用于数据库的 phpmyadmin网站 .

alwaysdata is the phpmyadmin website I use for my database.

我注意到这是当我尝试访问与数据库有关的某些页面时(例如,创建用户...等),而其他页面(如联系人")没有问题.

I noticed that it's when I try to access in some pages in relation with the database (create user for example... etc) and there's no problems with other pages like 'contact'.

我在Mac OSX上,我使用MAMP服务器,始终使用数据,laravel和Netbeans IDE.使我的项目与数据库之间的连接正确所需的所有配置.

I'm on mac OSX and I use MAMP server, always data, laravel and netbeans IDE. all configurations required to make the connection between my project and the database is correct.

这里是:

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

打开: /Applications/MAMP/htdocs/lesenfantsdurhone/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php

open: /Applications/MAMP/htdocs/lesenfantsdurhone/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php

 */
public function createConnection($dsn, array $config, array $options)
{
    $username = array_get($config, 'username');

    $password = array_get($config, 'password');

    return new PDO($dsn, $username, $password, $options);
}

如果有人有主意...

If someone have an idea...

谢谢.

推荐答案

端口为 own DSN中的参数:

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

或者,仅忽略该端口,默认端口为3306.

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

这篇关于SQLSTATE [HY000] [2005]未知的MySQL服务器主机'mysql1.alwaysdata.com:3306'(2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆