LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-22-2010, 09:55 PM   #16
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled

Hi -

Cool - thanx for the followup!

Here's where we're at:
Quote:
1. Of the million different things that *could* have been going wrong, we've narrowed the problem down to "mysql logon". We've verifies that mySQL, PHP and Apache are all OK; we've verified that you've got valid data, and we've verified that you can access that data from the mysql client. That's all progress - cool

2. The main things I tried to show in my last example were:
a) setting up the database (I kind of guessed you already had that squared away ... but I didn't want to "assume" anything )

b) calling mysql from PHP (a "simple as possible" example)

c) PHP error handling (the "or die()" stuff)
... and ...
d) "Simple as possible" HTML (no tables: just text and "<br/>" tags)
Try this:
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") 
    or die ("mysql_connect failed!");
'Hope that helps .. PSM
 
Old 04-22-2010, 11:56 PM   #17
tklMe
LQ Newbie
 
Registered: Mar 2010
Posts: 22

Original Poster
Rep: Reputation: 16
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?
 
Old 04-23-2010, 12:52 AM   #18
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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") 
    or die ("mysql_connect failed!");
Save and exit.
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
 
Old 04-23-2010, 07:46 AM   #19
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
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:
Originally Posted by paulsm4 View Post
5. Change your PHP code ("test.php") to this:
Code:
$conn = mysql_connect("localhost", "fred", "flintstone") 
    or die (mysql_error());
Save and exit.
Double-check the PHP file to make sure it's changed.
Are you sure that you need to add user nobody to the group mysql? I never do that. Seems to be a bit pointless as MySQL runs with its own user. Apache or actually I should say php contacts MySQL as a client, not as a daemon. I don't know what adding nobody to the mysql group implies for the security of MySQL.

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.
 
Old 04-23-2010, 09:43 AM   #20
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 04-23-2010, 11:45 AM   #21
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
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.
 
Old 04-23-2010, 01:23 PM   #22
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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!

Last edited by paulsm4; 04-23-2010 at 01:25 PM.
 
Old 04-23-2010, 07:30 PM   #23
tklMe
LQ Newbie
 
Registered: Mar 2010
Posts: 22

Original Poster
Rep: Reputation: 16
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.
 
Old 04-23-2010, 09:11 PM   #24
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
OK - please go into mysql and cut/paste the output of these commands:

Quote:
use mysql;
select Host,User from user;
 
Old 04-23-2010, 11:18 PM   #25
tklMe
LQ Newbie
 
Registered: Mar 2010
Posts: 22

Original Poster
Rep: Reputation: 16
PaulSM4: I am going to start from scratch and install from source. Hopefully this will fix the issue I am having.
 
Old 04-23-2010, 11:44 PM   #26
Carl Filby
Member
 
Registered: Aug 2008
Location: Deep East Texas
Distribution: Debian,Ubuntu
Posts: 36

Rep: Reputation: 15
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.
 
Old 04-24-2010, 12:18 AM   #27
tklMe
LQ Newbie
 
Registered: Mar 2010
Posts: 22

Original Poster
Rep: Reputation: 16
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!
 
Old 04-24-2010, 12:23 AM   #28
Carl Filby
Member
 
Registered: Aug 2008
Location: Deep East Texas
Distribution: Debian,Ubuntu
Posts: 36

Rep: Reputation: 15
Quote:
Originally Posted by tklMe View Post
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!
Ok
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.

Last edited by Carl Filby; 04-24-2010 at 12:27 AM.
 
Old 04-24-2010, 12:54 AM   #29
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
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.
 
Old 04-24-2010, 01:48 AM   #30
tklMe
LQ Newbie
 
Registered: Mar 2010
Posts: 22

Original Poster
Rep: Reputation: 16
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>
 
  


Reply

Tags
configuration, lamp



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing LAMP, easier said than done? anon091 Linux - Newbie 4 08-24-2009 10:52 AM
Need help configuring YUM zak4u Linux - Newbie 5 03-23-2009 06:32 AM
Installing lamp umwai Linux - Newbie 3 09-16-2008 11:58 PM
Configuring YUM taborekle Fedora 3 02-23-2006 01:35 PM
help configuring yum J0sep Fedora 1 01-13-2005 02:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration