donglunzai4288 2019-03-18 20:03
浏览 280
已采纳

php通过mysqli连接mysql数据库

I try to connect to a mysql database via PHPs mysqli.

define('DB_SERVER', '127.0.0.3');
define('DB_USERNAME', '570466');
define('DB_PASSWORD', 'pssst!');
define('DB_NAME', 'db570466');

/* Attempt to connect to MySQL database */
$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

And get the following error: Warning: mysqli::mysqli(): (HY000/1045): Access denied for user '570466'@'localhost' (using password: YES) in /.../config.php on line 16

The strange thing is, that Access is denied for my user @localhost, but I don't connect to localhost. According to my hoster (domainFactory), I can also connect to the DB via mysql5.my-domain.tld, but that gives me the same output.

What am I missing?

  • 写回答

2条回答 默认 最新

  • duanqin9631 2019-03-20 18:17
    关注

    According to the help pages, database usernames for DomainFactory should start with "db":

    Den Usernamen Ihrer Datenbank sehen Sie im Kundenmenü unter "MySQL-Datenbanken". Er hat das Format db12345 bzw. db12345_1 bei weiteren Datenbanken.

    (translated:)

    The username for your database can be found in the customer portal under "MySQL databases". It has the format db12345 or db12345_1 for subsequent databases.

    So you should be able to connect to the database "db570466" using the username db570466 instead of just 570466.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog