简体   繁体   English

无法连接到mysql服务器

[英]Can't connect to mysql server

I'm creating a php page (on a godaddy server) which needs to connect to a mysql server and retrieve data from a database. 我正在创建一个php页面(在godaddy服务器上),它需要连接到mysql服务器并从数据库中检索数据。 When i run the page i got an error message stating that. 当我运行页面时,我收到一条错误消息,说明这一点。

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on ** 警告:mysql_connect()[function.mysql-connect]:无法连接到MySQL服务器**

It says that the error is on the below line, 它说错误在下面,

$conn=mysql_connect($dbhost,$username,$password); $康恩=的mysql_connect($ DBHOST,$用户名,密码$);

My doubt is, 我怀疑是,

What needs to be given in place of username and password? 需要提供什么来代替用户名和密码? Right now i've given the username and password used while creating a new database inside mysql. 现在我已经给出了在mysql中创建新数据库时使用的用户名和密码。 What am i doing wrong? 我究竟做错了什么?

Thanks in advance... 提前致谢...

On shared go daddy DB's you can't use localhost for the $dbhost 在共享go daddy DB上你不能使用localhost作为$ dbhost

you will need to use the location specified in your godaddy mysql cp 你需要使用godaddy mysql cp中指定的位置

Do not use "localhost" as the hostname for your database-driven websites. 不要使用“localhost”作为数据库驱动的网站的主机名。 Once you have successfully created a database, your host name displays on the Database Information page of your hosting Control Panel. 成功创建数据库后,主机名称将显示在主机控制面板的“数据库信息”页面上。

To Find the Host Name for Your Database 查找数据库的主机名

  1. Log in to your Account Manager. 登录您的客户经理。
  2. Click Web Hosting. 单击“虚拟主机”。
  3. Next to the hosting account you want to use, click Launch. 在要使用的主机帐户旁边,单击“启动”。
  4. In the Databases section of the hosting Control Panel, click MySQL or MSSQL depending on the database type for which you want the host name. 在主机控制面板的“数据库”部分中,根据您想要主机名的数据库类型,单击“MySQL”或“MSSQL”。
  5. From your list of databases, click Actions next to the database you want to use, and then click Details. 从数据库列表中,单击要使用的数据库旁边的“操作”,然后单击“详细信息”。

Your database host name displays in the Hostname field. 您的数据库主机名显示在“主机名”字段中。

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

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