热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何让mysqli_connect工作?-Howtogetmysqli_connecttowork?

Iamtryingtousemysqli_connectassuch:我正在尝试使用mysqli_connect:$hostftp.tatiana-renae.com;

I am trying to use mysqli_connect as such:

我正在尝试使用mysqli_connect:

$host = "ftp.tatiana-renae.com";
$user = "tatiana";
$password = "********";
$dbname = "********";
$cOnnection= mysqli_connect($host, $user, $password, $dbname);

but I get this error:

但我得到这个错误:

Database connection failed: Can't connect to MySQL server on 'ftp.tatiana-renae.com' (111) (2003)

数据库连接失败:无法连接到'ftp.tatiana-renae.com'上的MySQL服务器(111)(2003)

I know mysqli_connect works differently than mysql_connect but I can't figure out what to do for mysqli_connect to make it happy. Any ideas?

我知道mysqli_connect与mysql_connect的工作方式不同,但我无法弄清楚如何为mysqli_connect做些让它开心。有任何想法吗?

1 个解决方案

#1


Error 111 is "connection refused". One candidate explanation is that MySQL is not "listening" on the network, but only the TCP loopback address.

错误111是“连接被拒绝”。一个候选解释是MySQL不是在网络上“监听”,而只是TCP环回地址。

Check the my.cnf for the server, and check if it contains lines like this:

检查my.cnf是否有服务器,并检查它是否包含以下行:

skip-networking 

or

bind_address=127.0.0.1

If your PHP is running on the same server as MySQL, you can try using '127.0.0.1' for the host, in place of 'ftp.tatiana-renae.com'.

如果您的PHP与MySQL在同一台服务器上运行,您可以尝试使用'127.0.0.1'代替'ftp.tatiana-renae.com'。

Is the MySQL server running? Can you connect to it using the mysql command line interface?

MySQL服务器是否正在运行?你可以使用mysql命令行界面连接到它吗?

There's several other possibilities; but there's not enough information provided about you environment for us to accurately diagnose the problem. We're just guessing.

还有其他几种可能性;但是我们没有提供足够的关于您的环境的信息来准确诊断问题。我们只是在猜测。


推荐阅读
author-avatar
深圳市互联网大会
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有