Hi -
Cool - thanx for the followup! Here's where we're at: Quote:
1. Please just use "localhost" as the server name (you'll recall everything is on the same PC. "Localhost" is an alias for the loopback address, 127.0.0.1). 2. Use your simple login name (instead "server-or-ip@name"). EXAMPLE: let's say your login is "fred", and your password "flintstone". Please try this: Code:
$conn = mysql_connect("localhost", "fred", "flintstone") |
PaulSM4: I actually did try it with just localhost and not server2.lambott.local and that didn't work.
I also used the drop command to remove the other user. I then just added tklamb without the IP. Granted all the privileges and then used the Flush command. (so a simple user name with a simple password) AMP is installed on the same virtual machine, however, I am logging into it from a different machine. Regardless it doesn't work on either system. And just to make certain I opened up the browser on server2 and tried to connect. Got the same message regardless of whether I used server2.lambott.local or localhost. Is there anything else you can suggest for me to try? |
Hi -
EXAMPLE: hostname: bedrock username: fred password: flintstone test file: test.php 1. Q: PHP, Apache, and MySQL are all running on "bedrock", correct? 2. Q: does it work if you a) log in to "bedrock" as user "fred"? b) mysql -ufred -pflintstone cats <= Q: are you able to log on to database "cats" this way, on this server? c) select * from mine; <= Q: do you see the expected data? 3. While you're in mysql, also do this: use mysql; select Host,User from user; <= Make sure User "fred" is in here, with Host "localhost" or "%" 4. Find out what user your Apache server is running as EXAMPLE: "ps -eaf|grep http", or "ps -eaf|grep apache" <= Usually, the Apache user will be "nobody" Verify that user (e.g. "nobody" belongs to the group "mysql") EXAMPLE: "groups nobody" <= should return "mysql" as one of the groups 5. Change your PHP code ("test.php") to this: Code:
$conn = mysql_connect("localhost", "fred", "flintstone") Double-check the PHP file to make sure it's changed. 6. Point your browser to "http://bedrock/test.php" Be sure to "refresh" every time you change and save "test.php" 7. Report back what you find. 'Hope that helps .. PSM |
I would use mysql_error() instead of your own custom message. This way we get the actual MySQL error. Although I am not sure if it works this way...
Quote:
The rest is a good procedure to follow, of course. Please also check the MySQL log. Usually it can be found at /var/log/mysqld.log. |
C'mon Blue_ice: I'm just trying to cover all the bases to get tklMe going as quickly as possible: just trying to make sure we leave *nothing* to chance.
Yes, I would definitely recommend adding the Apache user (which may or may not be "nobody" on his system) to the "mysql" group. And yes, looking at /var/log/mysqld.log is also a good idea. Looking at /var/log/messages and the Apache access and error logs wouldn't hurt, either ;) But the main thing is to make sure the combination of "host" and "username" he's using exactly matches a "Host/User" logon tuple in his MySQL "user" table. And that was the main gist of my suggestion. IMHO .. PSM |
Of course, you are right... I was just wondering why you added the apache user to the mysql group, as both can be on different machines. Maybe I have expressed myself in a wrong way. Sorry for that...
Actually, the die(mysql_error()) part is pretty interesting as it might return useful information on why the connection failed. Log files are interesting as well. We have never asked for it and tklMe hasn't posted it either. |
Hi again, Blue_ice -
The reason I suggested adding the Apache user to the mysql group is because it's possible to get a "can't open socket /var/lib/mysqld.sock" error unless the filesystem permissions (i.e. Linux group memberships) line up. Not saying it *is* what's happening - but definitely saying it *can* be an issue. And that it's no sweat to resolve (simply make sure the Apache user belongs to the mysql group). And yes, I totally agree about adding "mysql_error()" to the user-defined error message - great suggestion :) Your .. PSM PS: TklMe - good luck, and keep us posted! |
PaulSM4:
1. Q: PHP, Apache, and MySQL are all running on "bedrock", correct? --> yes, if by bedrock you mean server2.lambott.local which is the hostname listed in the network configuration screen. 2. Q: does it work if you a) log in to "bedrock" as user "fred"? --> into server2.lambott.local as tklamb, yes b) mysql -ufred -pflintstone cats <= Q: are you able to log on to database "cats" this way, on this server?--> no c) select * from mine; <= Q: do you see the expected data? --> only if I log in without the above and change to the database and then select the table. 3. While you're in mysql, also do this: use mysql; select Host,User from user; <= Make sure User "fred" is in here, with Host "localhost" or "%"-->user tklamb is listed with a %. 4. Find out what user your Apache server is running as EXAMPLE: "ps -eaf|grep http", or "ps -eaf|grep apache" <= Usually, the Apache user will be "nobody" --> all this is showing me is either root or apache not sure where it is suppose to show me a user. Remember I am new to this stuff. Also, I tried blueice's suggestion and changed the error code to the mysql_error() and I'm either getting an "access denied" or an "unknown MySQL server host" error depending on whether I am logging in under localhost or server2.lambott.local. The localhost (even if I try to log in as root) will give me the access denied and the server2.lambott.local will give me the unknown server error. |
OK - please go into mysql and cut/paste the output of these commands:
Quote:
|
PaulSM4: I am going to start from scratch and install from source. Hopefully this will fix the issue I am having.
|
OP
I am not by any definition of the word a php man or webmaster but I do see a couple discrepancies in your php code http://www.linuxquestions.org/questions/attachment.php?attachmentid=3409&d=1271893671 echo " <td>{$row[age]}</td>\n"; echo " <td>{$row[id]}</td>\n"; "age" & "id" are not in quotes like name & sex is. Could that explain why execution of your script is failing to produce output after first table. |
Carl: I actually did try without the quotes but that didn't work either. Installing mysql from an rpm has proven to be a pain in the arse. The mysql command comes back with an error. Where the heck did it put this program? AAARRRGGGHHH!
|
Quote:
good luck and keep us posted..I am bookmarking this thread to monitor. I am particularly interested because I testing out Centos 5.4 now. I took a class on org RedHat back in 2004 but this is different lol. |
By default you cannot log in with root on a server remotely. This means the server name must be localhost when logging in. To see if your other usesers have access to the server, you have to run 'select Host,User from user;' as suggested by paulsm4.
The unknown server error could mean that it was not possible to resolve the computername, so you might want to try the ipaddress there. |
PaulSM4: I gave up on the source install...too much of a headache right now. I was having issues with the mysql install and I figured I would also have issues with the ssl. So, back to the beginning. Here is the output:
mysql> use mysql; Database changed mysql> select Host, User from user; +-----------------------+---------+ | Host | User | +-----------------------+---------+ | % | lambott | | % | tklamb | | 127.0.0.1 | root | | localhost | | | localhost | root | | server2.lambott.local | | | server2.lambott.local | root | +-----------------------+---------+ 7 rows in set (0.00 sec) mysql> |
All times are GMT -5. The time now is 09:35 PM. |