简体   繁体   English

使用php连接到mysql DB

[英]connect to mysql DB using php

I tried to connect to my DB server using the hostname and the port in the file config.php but still give me error, I won't use the localhost server, the database is in other server. 我尝试使用文件名config.php中的主机名和端口连接到我的数据库服务器,但仍然给我错误,我不会使用本地主机服务器,数据库位于其他服务器中。 I get the hostname using : show variables like '%hostname%' and get the port using : SHOW VARIABLES WHERE Variable_name = 'port' 我使用以下命令获取主机名: show variables like '%hostname%'并使用以下命令获取端口: SHOW VARIABLES WHERE Variable_name = 'port'

define('DB_USER', "test"); 
define('DB_PASSWORD', "test"); 
define('DB_DATABASE', "test"); 
define('DB_SERVER', "My problem is here"); 

someone know what I did wrong? 有人知道我做错了吗?

thank you 谢谢

Some hosts, you can't connect to their database from your localhost, but only from their webserver. 对于某些主机,您无法从本地主机连接到其数据库,而只能从其Web服务器连接到它们。

Maybe thats your problem ? 也许这就是您的问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM