php与mysql无法连接是什么原因?
我的系统装好了,我装的是redhat-9.0默认安装了mysql数据库,安装完成后所有的服务都是正常的,可是用网页程序检测不到mysql大家看一下:
[root@localhost root]# /etc/rc.d/init.d/mysqld stop
停止 MySQL: [ 确定 ]
[root@localhost root]# /etc/rc.d/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost root]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>; \s
--------------
mysql Ver 11.18 Distrib 3.23.54, for redhat-linux-gnu (i386)
Connection id: 1
Current database:
Current user: root@localhost
Current pager: stdout
Using outfile: ''
Server version: 3.23.54
Protocol version: 10
Connection: Localhost via UNIX socket
Client characterset: latin1
Server characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 7 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.286
--------------
mysql>; \q
Bye
[root@localhost root]#
请问是不是我的这个php.ini配置错了,请问这点应该怎么配置?
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1
; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1
; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =
; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password"
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
装上php-mysql那个包。
Server localhost
Error
MySQL said:
#2002 - Can't connect to local MySQL server through socket 'mysql_connect' (2)
[Documentation]
十分感谢好好先生的指点,不过我安装phpmyadmin出现这种错误是什么原因?
编辑你的config.inc.php加入你的mysql的主机名,用户名,密码。
好好先生你好,我想请教你一个问题,我想为大家提供免费的php+mysql空间可是现在我无法控制用户的空间配额,请问如何才能限制空间呢?
http://bbs.cnlinux.org/viewtopic.php?t=4
这个帖子你看一下,希望你可以回复这个帖子,谢谢了!