Forum Moderators: coopster

Message Too Old, No Replies

mySQL Access

Apache issue?

         

Russ49Checkmate

6:10 am on Jul 21, 2004 (gmt 0)

10+ Year Member



I'm very new to this UNIX stuff but I'm definately loving mySQL for the price I paid.

I'm using PHP to build the front end to the db on a G4 iMac running Panther. Everything works as expected while I use my own (standard) account. I grab the resultset and post the data into an HTML table.

$link = mysql_connect("localhost", "Dad", "password")
or die("Could not connect : " . mysql_error());

However, from my dear wife's (administrator) account, the table cells are empty, no data from mySQL.

I don't think the user_name or password is an issue because I can use the shell to run the "Dad" mySQL account from "Mom" UNIX account.

I tried the "wildcard" for host with this result:

Could not connect : Unknown MySQL Server Host '%' (22)

I'm pretty much out of my league here, the permissions in mySQL seem to be correct. Anyone have any thoughts on this?

henry0

11:57 am on Jul 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you running this locally?
And is Mac like for example Red Hat that offers a root account (possibly you) with "all privileges" then other users do not indeed have root access therefore the MySQL "password" is left empty and there is no handshake
If so try allowing other accounts with enough privileges

you can allow/specify privileges through PHP MyAdmin

timster

1:55 pm on Jul 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm using PHP to build the front end to the db on a G4 iMac running Panther. Everything works as expected while I use my own (standard) account. I grab the resultset and post the data into an HTML table.

Something funky is going on, since I do this frequently on my Macs without trouble.

$link = mysql_connect("localhost", "Dad", "password")
or die("Could not connect : " . mysql_error());

However, from my dear wife's (administrator) account, the table cells are empty, no data from mySQL.

So she's gettting to the Web page, the Web page loads, but with blank table rows? Does your "Could not connect" error appear?

I don't think the user_name or password is an issue because I can use the shell to run the "Dad" mySQL account from "Mom" UNIX account.

That's right. You should even be able to connect from a Web server on a different computer this way (assuming you change "localhost" to your computer's IP address.)

I tried the "wildcard" for host with this result:

Could not connect : Unknown MySQL Server Host '%' (22)

If you are successfully connecting with "localhost" as the host name, we can leave that alone for now.

I'm pretty much out of my league here, the permissions in mySQL seem to be correct. Anyone have any thoughts on this?

Maybe take a closer look at the PHP or SQL code, or even the HTML code that is output to the page. Echoing your SQL query to your Web page can solve a lot of mysteries.

timster

2:01 pm on Jul 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Regarding Henry0's Q,

FYI, Mac OS X has 2 kinds of login users, Administrators and non-Administrators. It looks like "Mom" and "Dad" are both administrators in this case. (Apple makes getting root access difficult, except through

sudo
.)

But even non-Administrators should be able to run the Web page -- just tested it here.

StupidScript

4:23 pm on Jul 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are not getting the "Could not connect" error, and seeing no resulting dataset from your query, then I would be looking at (a) the query and (b) your code for displaying the dataset.

Without that error, it would seem that your permissions are fine.

Worst-case scenario, as MySQL admin:

grant insert,select,delete,update,drop,create on databasename.* to Dad@localhost identified by 'password';

Regardless of any other security measures in the Mac OS, if that's where the installation is running, this should allow Dad full access to the database.

Please post the rest of your code, from the connection to the db through the data gathering attempt to the closing of the db connection. That will help us help you better.

:)

Russ49Checkmate

9:26 pm on Jul 21, 2004 (gmt 0)

10+ Year Member



Found the problem ....

REALLY stupid!

I was calling the page from the Mom account as a file
file:///Users/Dad/script.php.

Should be:
[127.0.0.1...]

I'm too embarrassed to post the actual code, this was the first of about 15 scripts I wrote. By the fifteenth script, I had things under better control. No more 7 resultsets from the same table [giggle].

Thanks everyone for your input and thanks jatar_k for your hard work.