栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

无法通过套接字连接到本地MySQL服务器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

无法通过套接字连接到本地MySQL服务器

由于对该错误的调用引发了错误,

mysql_real_escape_string()
因此它意味着您没有
mysql_connect()
先调用该错误并将有效的数据库句柄传递给
mysql_real_escape_string
(或调用
mysql_connect()
失败)。

在某些情况下,mysql扩展将尝试使用php.ini中的默认设置自动连接,如果这些设置不可用,则故障转移至my.cnf-
显然无效。也可能是设置有效,但是mysqld没有运行。

您是否具有成功连接到数据库的脚本?

您有数据库的用户名和密码吗?

尝试:

check_running();$user=''; // fill in your details$password=''; // fill in your details$hosts=array(  'localhost', '127.0.0.1', $_SERVER['HTTP_HOST'], $_SERVER['SERVER_ADDR']);foreach ($hosts as $addr) {   try_con($addr, $user, $password);   try_con($addr . ':3306', $user, $password);}function try_con($host, $user, $password){ $dbh=mysql_connect($host, $user, $password); if ($dbh) {     print "Connected OK with $host, $user, $password<br />n"; } else {     print "Failed with $host, $user, $password<br />n"; }}function check_running(){   // this assumes that you are using Apache on a Unix/Linux box   $chk=`ps -ef | grep httpd | grep -v grep`;   if ($chk) {      print "Checking for mysqld process: " . `ps -ef | grep mysqld | grep -v grep` . "<br />n";   } else {       print "Cannot check mysqld process<br />n";   } }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418792.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号