Chinaunix

标题: 求助mysql连接错误 [打印本页]

作者: xpingtn    时间: 2008-07-25 14:30
标题: 求助mysql连接错误
本人搭建LAMP环境,放了一个phpbb3.0的论谈,连接数据库时提示如下

php连接错误.JPG (51.71 KB, 下载次数: 97)

php连接错误

php连接错误

作者: xpingtn    时间: 2008-07-25 14:34
接上
在命令提示符下SHELL>mysql -u root -p 一点问题都没有可以创建库
我编译mysql时用的参数为
./configure --prefix=/site/lamp/mysql \
--with-embedded-server \
--without-debug \
--enable-assembler \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-unix-socket-path=/site/lamp/mysql/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--without-innodb \
--enable-thread-safe-client

网上搜索了一上,可以用telnet的方法试一下3306端口,我连了一下,能telnet过去但马上就断开了,不知道为什么??请DBA高手帮忙解决一下。谢了
作者: xpingtn    时间: 2008-07-25 16:11
使用mysqladmin -u root -pXXXXXX version
mysqladmin  Ver 8.41 Distrib 4.1.20, for redhat-linux-gnu on i386
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.56
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /opt/lamp/mysql/tmp/mysql.sock
Uptime:                 1 hour 50 min 5 sec

Threads: 1  Questions: 13  Slow queries: 0  Opens: 12  Flush tables: 1  Open tables: 7  Queries per second avg: 0.002

不知道这个是否显示正常
作者: xpingtn    时间: 2008-07-25 16:13
用telnet 192.168.1.200 3306 错误如下

EHost '192.168.1.60' is not allowed to connect to this MySQL server

失去了跟主机的连接。
作者: xpingtn    时间: 2008-07-25 16:14
怎么没人知道呢????
作者: xpingtn    时间: 2008-07-25 16:47
我使用mysqladmin -h localhost variables查看mysql的port值为3306,但telnet IP 3306却“提示不允许连接MySQL Server",有谁帮我解决。。。
作者: yueliangdao0608    时间: 2008-07-25 17:19
192.168.1.200

这个主机确认有给他用户嘛?
作者: xpingtn    时间: 2008-07-25 17:22
有的,我可以用
SHELL>mysql -u phpbbs -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.56

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use bbs;
Database changed
mysql>
作者: xpingtn    时间: 2008-07-25 17:27
我用别的程序测试连接到数据库提示如下错误:
--------------------------------------------------------------
系统提示:不能连接到 MySQL 服务器 localhost
错误信息:Can't connect to local MySQL server through socket '/opt/lamp/mysql/tmp/mysql.sock' (13)
错误代码:2002
--------------------------------------------------------------
作者: yueliangdao0608    时间: 2008-07-26 09:34
Show your result of statement select user,host from mysql.user !
作者: 枫影谁用了    时间: 2008-07-27 12:48
你在一台装有MYSQL客户口端的机器用mysql -h xxx.xxx.xxx.xxx -u root -p 连接看一下可不可以连。

连上后seelct * from mysql.user看看。
作者: xpingtn    时间: 2008-07-27 21:55
mysql> select user,host from mysql.user;
+----------+-----------------------+
| user     | host                  |
+----------+-----------------------+
| root     | 127.0.0.1             |
|          | localhost             |
| bbs      | localhost             |
| root     | localhost             |
| vpopmail | localhost             |
|          | localhost.localdomain |
| root     | localhost.localdomain |
+----------+-----------------------+
作者: 枫影谁用了    时间: 2008-07-27 21:57
原帖由 xpingtn 于 2008-7-27 21:55 发表
mysql> select user,host from mysql.user;
+----------+-----------------------+
| user     | host                  |
+----------+-----------------------+
| root     | 127.0.0.1             |
| ...


phpbb3.0和MYSQL是在同一台机器吗?
作者: 枫影谁用了    时间: 2008-07-27 22:01
问题应该在这里!

--with-unix-socket-path=/site/lamp/mysql/tmp/mysql.sock

/opt/lamp/mysql/tmp/mysql.sock

第一个是你编译的sock,第二个是你程序连的sock。呵呵


用IP连试下,不要填localhost用eth0的IP。
作者: 枫影谁用了    时间: 2008-07-27 22:03
或用127.0.0.1

还有my.cnf里的sock配置是在那里?

启动MYSQL后这个文件不存在这个路径吧/opt/lamp/mysql/tmp/mysql.sock
作者: xpingtn    时间: 2008-07-28 16:17
谢谢各位帮助,我编译mysql时其实带的参数是这样的
./configure --prefix=/opt/lamp/mysql \
--with-embedded-server \
--without-debug \
--enable-assembler \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-unix-socket-path=/opt/lamp/mysql/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--without-innodb \
--enable-thread-safe-client

如果没有mysql.sock这个文件我知道,mysql服务器可能启动不了,如果可以启动,用
mysql -u root -p连过去也是出错的,会提示找不到socket文件
vi /etc/my.cnf
**************************
# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /opt/lamp/mysql/tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
socket          = /opt/lamp/mysql/tmp/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
******************************

ls /opt/lamp/mysql/tmp/
[root@mail log]# ls /opt/lamp/mysql/tmp/
mysql.sock

我这个目录下有这个文件的
作者: xpingtn    时间: 2008-07-28 16:20
还有phpbb3.0和MYSQL是装在同一台机器上的,这样不会有问题吧!!
作者: 枫影谁用了    时间: 2008-07-28 16:23
mysql -S /opt/lamp/mysql/tmp/mysql.sock -u root -p


这样可以连吗?
作者: 枫影谁用了    时间: 2008-07-28 16:32
原帖由 xpingtn 于 2008-7-28 16:20 发表
还有phpbb3.0和MYSQL是装在同一台机器上的,这样不会有问题吧!!


这个倒不会。^_^
作者: xpingtn    时间: 2008-07-28 16:35
mysql -S /opt/lamp/mysql/tmp/mysql.sock -u root -p
可以连的
作者: yueliangdao0608    时间: 2008-07-29 16:08
看看这里

http://topic.csdn.net/u/20071229 ... 4-ba412f94d99d.html
作者: 枫影谁用了    时间: 2008-07-29 16:30
楼上的兄弟好像在CSDN逛得很多哩!到处看你发CSDN的贴^_^
作者: yueliangdao0608    时间: 2008-07-29 16:37
标题: 回复 #22 枫影谁用了 的帖子
解决问题就好,不管是哪里的帖子!!
作者: 枫影谁用了    时间: 2008-07-29 20:48
原帖由 yueliangdao0608 于 2008-7-29 16:37 发表
解决问题就好,不管是哪里的帖子!!

那倒是
作者: xpingtn    时间: 2008-07-31 17:57
好的,谢谢了,我回去试一下。
作者: xpingtn    时间: 2008-08-02 21:50
还是不行呀,总是提示那个socket有错误.
作者: gogo407    时间: 2008-08-03 01:01
做个链接吧
ln -s /opt/lamp/mysql/tmp/mysql.sock   /tmp/mysql.sock
除非你修改php.ini的默认的mysql.sock 的位置
:)




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2