VPS侦探论坛

 找回密码
 注册
查看: 8287|回复: 7

数据库错误Can not connect to database

[复制链接]
发表于 2012-4-5 12:21:13 | 显示全部楼层 |阅读模式

军哥,求救,数据库错误

出现错误!
错误原因:Can not connect to database!
error: Access denied for user 'root'@'localhost' (using password: YES)
返 回 并修正

其他网站可以正常连接数据库,且用户名及密码均正确。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-4-5 12:29:08 | 显示全部楼层


发现有时如果主站能访问,子站就会出现上面的数据库链接错误;如果主站出现502 bad gateway ,子站就能访问。
[root@li408-51 ~]# ./lnmpa status
=========================================================================
Manager for LNMPA V0.8  ,  Written by Licess
=========================================================================
LNMPA is a tool to auto-compile & install Nginx+MySQL+PHP+Apache on Linux
This script is a tool to Manage status of LNMPA
For more information please visit http://www.lnmp.org

Usage: /root/lnmpa {start|stop|reload|restart|kill|status}
=========================================================================
Nginx is runing!
/etc/init.d/httpd: line 112: lynx: command not found
SUCCESS! MySQL running (2136)
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-4-5 12:31:33 | 显示全部楼层

[root@li408-51 ~]# php -v
PHP 5.2.17p1 (cli) (built: Apr  5 2012 03:47:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

[root@li408-51 ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-4-5 12:33:28 | 显示全部楼层



[root@li408-51 ~]# vi /usr/local/mysql/var/li408-51.err
120322 23:03:39 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
120322 23:03:39 [Note] Event Scheduler: Loaded 0 events
120322 23:03:39 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.1.60-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
120322 23:03:40 [Note] /usr/local/mysql/libexec/mysqld: Normal shutdown

120322 23:03:40 [Note] Event Scheduler: Purging the queue. 0 events
120322 23:03:40 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

120322 23:03:40 mysqld_safe mysqld from pid file /usr/local/mysql/var/li408-51.pid ended
120322 23:03:41 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
120322 23:03:41 [Note] Event Scheduler: Loaded 0 events
120322 23:03:41 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.1.60-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
120322 23:03:42 [Note] /usr/local/mysql/libexec/mysqld: Normal shutdown

120322 23:03:42 [Note] Event Scheduler: Purging the queue. 0 events
120322 23:03:42 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
"/usr/local/mysql/var/li408-51.err" 227L, 14210C
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-4-5 13:58:44 | 显示全部楼层

可能mysql密码错误,或127.0.0.1和localhost的root密码不一样

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2012-4-5 16:58:18 | 显示全部楼层

服务器里放有四个网站,都用同样的用户名及密码(任何帐户都设置了同样密码),而地址都是用localhost,其余三个都没有问题,只是第四个出现database error。诡异的是,第四个网站的数据库错误不是一直都存在的,是间段的,第四个网站与主网站的数据库都比较大,网站文件占硬盘总空间也是最大的——当主网站访问正常时,第四个网站表现为数据库错误,当第四个网站访问正常时,主网站表现为502 bad gateway。
 楼主| 发表于 2012-4-5 17:00:12 | 显示全部楼层

会不会是数据库对同时间数据流量设置了限制所致?
如果是,应该如何修改?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-4-6 09:35:09 | 显示全部楼层

那就不清楚了,数据库上不可能设置流量限制
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-17 03:42 , Processed in 0.027636 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表