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

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP