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条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料