List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:June 7 1999 5:13pm
Subject:MySQL-3.22.22 and passwords
View as plain text  
>>>>> "hUnTeR" == hUnTeR  <hunter@stripped> writes:

hUnTeR> Dear list readers - 
hUnTeR> I recently upgraded my MySQL installation to 3.22.22 from 3.21.30. I
hUnTeR> have a general, and probably silly question. For some reason now,
hUnTeR> whenever i try to do something (i.e. mysqlshow) I get an error such as
hUnTeR> the following:

hUnTeR> /home/httpd/html/ mysqladmin version
hUnTeR> mysqladmin: connect to server at 'localhost' failed
hUnTeR> error: 'Access denied for user: 'root@localhost' (Using password: YES)'

hUnTeR> The only way i can get this to work is to use the -p parameter from the
hUnTeR> command line and then i must hit enter once it asks me for the password.
hUnTeR> such as the following:

<cut>

This means that you have a wrong password in a my.cnf file somewhere!
Check the files /etc/my.cnf and ~/.my.cnf !

<cut>

hUnTeR> Now here is my question. I am trying to write some php3 scripts to call
hUnTeR> a certain db i have written and am testing but i am unable to connect
hUnTeR> because i cant pass the password to the server. Is there anyway around
hUnTeR> this? Is there a way to pass the password to the server in the php3
hUnTeR> script? Here is a snippet of the script i am using to test:

hUnTeR> <?php
hUnTeR> $db = mysql_connect("localhost", "root");
hUnTeR> mysql_select_db("mydb",$db);
hUnTeR> $result = mysql_query("SELECT * FROM employees",$db);
hUnTeR> printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
hUnTeR> printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));
hUnTeR> printf("Address: %s<br>\n", mysql_result($result,0,"address"));
hUnTeR> printf("Position: %s<br>\n", mysql_result($result,0,"position"));
hUnTeR> ?>

hUnTeR> Any ideas? Any help would be appreciated. I would LOVE to turn off the
hUnTeR> password requirements to all but any secure db's i have or will write.
hUnTeR> Is this possible?

Just add the password as a 3:rd parameter to mysql_connect. If you
don't want to save the password in your script, you should save it on
a file somewhere and let your script read the password from the file.

Regards,
Monty
Thread
MySQL-3.22.22 and passwordshUnTeR7 Jun
  • MySQL-3.22.22 and passwordsMichael Widenius7 Jun