Jump to content
xisto Community
Sign in to follow this  
nakulgupta

MySQL Database Problems

Recommended Posts

My friends have a little forum running here. The problem is that quite often we get the following message when we try to open the page:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 48
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 330

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 331
phpBB : Critical Error

Could not connect to the database


Why does this happen and what can we do to avoid it??

Share this post


Link to post
Share on other sites

Hey.. :)I've often had that problem.. most often than not .. its because of incomplete transfers of files due to lost packets while you FTP. As a solution to this, I do the following:1. re-upload the concerned file causing the problem as dictated by the error message (preferably re-upload the entire folder)2. Check all files for consistancy with the files on your local system. I do this using the Compare Directories function in LeechFTP although I do all my file transfers using WSFTP. 3. Check and recheck your config files to make sure you've got all the settings correct. Especially the settings that connect you to the DB.Usually, these steps should get you up and running. if it doesn't, then you may have a problem with your DB.. To cure any problems with that.. I'd suggest you Backup the tables with user data, as well as post data and dump your entire DB, drop all tables in your DB, run the SQL file that came with your installation of bb. .. and then re-populate the tables as required with all the user and post data... (DO all this only if you feel you've exhausted all other solutions, and feel compitent to do it)Hope this helped.. :(Rashid

Share this post


Link to post
Share on other sites

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 48

 

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 330

 

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 331

phpBB : Critical Error

 

Could not connect to the database

<{POST_SNAPBACK}>


This is a server side error which only the webserver admin can correct.

 

mySQL servers have limited connections capability as of version 3.x, the max user can be atmost 100 connections.. at mySQL version 4.x, the connection goes up to 500 - 1000 connections as far as the last release I have on my pc.

 

Connection limit is base on the maximum current connections the server can handle.

 

Most of the time, mySQL server can process each query at a microsecond speed but there arise the question why some webservers encounter the error above.

 

1. First is that when mySQL server is accessed on the internet, there are countless of visitor that can access the website at any given time giving way to hammering and filling up all the connection slots to the servers.

 

2. Shared webserver hostings with shared connection poll will also trigger this event since assuming that there are 100 hosted sites sharing the same mySQL server with the same connection limit. If all 100 websites have 1 visitor at the exact time and 1 new visitor visits the same site at the same exact time, one of them will get that socket error if the max connection limit is 100.

 

3. There are times that we make scripts that connect to the database that are malformed. Malformed since they lack the full cycle of connection to the server. The full cycle is

 

a) locate server

:P connect and open connection

c) process query

d) disconnect and close connections

 

sometimes, we forget the closing part or we have a database connection command that are unreachable to the scripts.

 

Unclose connections stayed up in the server. For us the connection is finished but for the server, it will dutifully waits for the the client softwares or programs to send their disconnect commands.

 

For every unclose connection, a connection slot is taken and on default installation, the autotimeout of the database sometimes is set to 45mins.

 

 

--------------

 

Hope i solve the problem, the best solution is to contact the server admin for some assistance since mostly the settings are beyond your control.

 

geez, this seems so long, maybe I should put this one as a tutorial :P

Share this post


Link to post
Share on other sites

It looks a problem in your code. You sould take a look there to fix it up.The fist line is telling you that there is problem in your code avoiding that it appers in another words could not connect to the server.2nd = second there is a wrong argument.3rd = A political security from your forum phpBB

Share this post


Link to post
Share on other sites

It looks a problem in your code. You sould take a look there to fix it up.

 

The fist line is telling you that there is problem in your code avoiding that it appers in another words could not connect to the server.

2nd = second there is a wrong argument.

3rd = A political security from your forum phpBB

<{POST_SNAPBACK}>


Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 48Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 330Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 331phpBB : Critical ErrorCould not connect to the database*

im sorry but I do believe that you have a misconception about the problem. The real error is the socket can no longer accept the connection.

 

the next errors are the results of the 1st error.

 

since the socket cannot process the request made and the webserver cannot create a connection, then mysql4.php also cannot finish its connection routine thus it output the errors that it have invalid arguments.

 

in short, mysql4.php expects that it eithers get granted to access or be denied to the database.. since it cannot verify either of the two, it just output a generic error that there are some invalid arguments.. actually the one that output that are the webservers.

Share this post


Link to post
Share on other sites
what is it? MySQL Database ProblemsWarning: mysql_connect() [function.Mysql-connect]: Access denied for user (using password: YES) in z:homelocalhostwwwforumdbmysql4.Php on line 48Access denied for user '' (using password: YES) 
Please help!
 
-question by tohir

Share this post


Link to post
Share on other sites
Access denied for user MySQL Database Problems

Access denied for user 'Username'@'%' to database 'mydatabase'Hi,Am geting the message above once I try to connect to the database. This message stated to appear, although no changes where done to the database or the PHP code related to it.Can uou kindly advise why this has happened!!Thanks

-question by Maden72

Share this post


Link to post
Share on other sites

Look this problem generally occurs when the VAR and ETC directory of MySQL database gets corrupted which causes problems at the startup and also while transfering the files throufh FTP protocol. So, you need to repair it first.

Use inbuilt utilities likeMyisamchk’ and others to find and resolve the problem. But if it fails then you need to use any third party software like MySQL Repair software to resolve the issue. And to avoid the problem further you need to be little bit cautious while transfering the files through FTP like avoid huge file sizes etc. 

All the Best!

-reply by Nancy Johnson

Share this post


Link to post
Share on other sites
Mysql Query Limit ExcedMySQL Database Problems

Hi, All, I am using joomla base website, I often see the above error, I don't know How I fix it. If anybody help, I will be thankful to you.

I have any idea, on database error, If we switch the database login user to another user. Is it possible, If yes, then How?

 

Thanks in advance

-reply by Ahsan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.