无法让mysql_connect工作 [英] Cannot get mysql_connect to work
问题描述
我正在尝试做一些非常简单的事情 - 连接到
MySQL数据库。这是调用,然后是错误消息。
$ conn = mysql_connect(" localhost"," root","");
警告:mysql_connect():无法通过
socket''/ var / lib / mysql / mysql.sock''(13)连接到本地MySQL服务器
/ b / html / buildhw.php
第13行
失败
我也试过这个主持arg为",但我得到相同的
结果。以root身份登录也没有任何区别。
非常感谢任何帮助。
谢谢,
M. McDonnell
Hi,
I''m trying to do something which should be very simple - connect to the
MySQL database. Here is the call, followed by the error msg.
$conn = mysql_connect("localhost", "root", "");
Warning: mysql_connect(): Can''t connect to local MySQL server through
socket ''/var/lib/mysql/mysql.sock'' (13) in /var/www/html/buildhw.php on
line 13
failed
I''ve also tried this with the host arg as "", but I get the same
result. Logging on as root made no difference either.
Any help would be very much appreciated.
Thanks,
M. McDonnell
推荐答案
conn = mysql_connect(" localhost"," root","");
警告:mysql_connect():无法通过
socket''/ var / lib / mysql / mysql.sock'连接到本地MySQL服务器(13)在/var/www/html/buildhw.php上
第13行
失败
我已经也尝试使用主机arg作为",但我得到相同的
结果。以root身份登录也没有任何区别。
非常感谢任何帮助。
谢谢,
M. McDonnell
conn = mysql_connect("localhost", "root", "");
Warning: mysql_connect(): Can''t connect to local MySQL server through
socket ''/var/lib/mysql/mysql.sock'' (13) in /var/www/html/buildhw.php on
line 13
failed
I''ve also tried this with the host arg as "", but I get the same
result. Logging on as root made no difference either.
Any help would be very much appreciated.
Thanks,
M. McDonnell
Michael写道:
Michael wrote:
我正在努力做一些非常简单的事情 - 连接到MySQL数据库。这是调用,然后是错误消息。
Hi,
I''m trying to do something which should be very simple - connect to the
MySQL database. Here is the call, followed by the error msg.
conn = mysql_connect(" localhost"," root","");
警告:mysql_connect():无法通过/ var /中的套接字''/var/lib/mysql/mysql.sock'(13)连接到本地MySQL服务器www / html / buildhw.php on
第13行
我也尝试过将主机arg作为",但我得到了相同的<结果。以root身份登录也没有任何区别。
任何帮助都将非常感谢。
谢谢,
M. McDonnell
conn = mysql_connect("localhost", "root", "");
Warning: mysql_connect(): Can''t connect to local MySQL server through
socket ''/var/lib/mysql/mysql.sock'' (13) in /var/www/html/buildhw.php on
line 13
failed
I''ve also tried this with the host arg as "", but I get the same
result. Logging on as root made no difference either.
Any help would be very much appreciated.
Thanks,
M. McDonnell
你可能想调整你的php.ini for mysql。
寻找[MySQL]然后是这样的行:
;本地MySQL连接的默认套接字名称。如果为空,则使用内置的
; MySQL默认值。
mysql.default_socket =
我怀疑你的mysql已被编译为没有套接字文件
/ TMP /的mysql.sock。事实上,它似乎在/var/lib/mysql/mysql.sock。
快速检查/etc/my.cnf会告诉你它应该在哪里。
-david-
You may want to adjust your php.ini for mysql.
Look for [MySQL] and then the lines like this:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
I suspect your mysql has been compiled not to have the socket file in
/tmp/mysql.sock. In fact, it appears to be in /var/lib/mysql/mysql.sock.
A quick check of /etc/my.cnf will tell you where it should be.
-david-
这篇关于无法让mysql_connect工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!