1
votes

Ok, I have a really stupid problem here, and I'm starting to get really upset.

Just a few minutes ago, I could run my website on localhost with no problems. It's running in apache2 on the same machine as mySQL (an Ubuntu box).

I changed PHP's timezone and file upload size limit, then restarted both apache and mysql.

Now when I try to run the site from apache on the server, it can no longer select the database. As far as I can tell, it doesn't have a problem actually connecting to mysql, but when I run mysql_selectdb, it doesn't work.

If I run this site from my laptop, connecting to it via my home network, it works flawlessly.

I'm really really frustrated right now because it was working just fine minutes ago. I don't remember even changing any mySQL settings.

Can someone please help me figure out how this happened, and how to fix it? I really need to get this working as soon as possible.

EDIT: Here's the code I'm using to connect:

mysql_connect($serverUrl,'xx','xxx');
@mysql_selectdb('mydatabase') or die(mysql_error());

EDIT 2: When I use the root user login, it works just fine. To the best of my knowledge, I have given root access to the user I was using before, but I guess I could be wrong. Here is the command I was using in mySQL to give access:

GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';
1
Do you get any errors when trying to select your db? - Cyclonecode
add or die(mysql_error()); to the end of your mysql lines and run the script. That should point you in the right direction. - Grexis
Try reverting your php.ini to the previous settings, and maybe post some code. Also what does selectdb return? Aren't any errors thrown? - Viruzzo
the error is 'Access denied for user 'www-data'@'localhost' (using password: NO)' ... wtf?? the user i'm using is definitely not 'www-data'. Thank you, Grexis, for that tip. I have no idea what I'm doing. - Jimmy

1 Answers

1
votes

the user i'm using is definitely not 'www-data'.

My guess is you're using one of the mysql_* functions before you establish the connection. That will make the mySQL library use default login data - which, in your case, fail.

Check out the file name and line number of your error message to see where it gets triggered.