MySQL Forums
Forum List  »  Newbie

username question
Posted by: peter michaux
Date: May 10, 2005 11:20PM

Hi,

I just installed MySQL on my Mac with OS X 10.3, Apache and PHP. I thought installing and getting started with MySQL would be tricky like a lot of developer stuff on unix machines with builds and everything. It was easy!! And the online tutorial/reference got me going in minutes. Really great! Thanks to everyone developing MySQL!!! My question...

When I am in my terminal shell and I want to start a MySQL session I can type either

$mysql

or

$mysql -h localhost -u root -p
PASSWORD:

I do not have to enter any password. i just hit enter.

I worked though the menagerie database creation tutorial and want to try using php to get information from the database. However I am having username problems when I try to connect to the database with php.

How do I set up a proper username? Or do i have to? I'm confused. I've included my php file below to show you one of the things that I tried.

Thanks,
Peter

<html>
<head><title>Connect Server</title></head>

<body>

<?
$db="managerie";
$link = mysql_connect("localhost",$_POST['root'],$_POST[''])or die("Connect Error: ".mysql_error());
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query("SELECT * FROM pet") or die("Connect Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
mysql_close($link);
?>

</body>
</html>

Options: ReplyQuote


Subject
Written By
Posted
username question
May 10, 2005 11:20PM
May 10, 2005 11:26PM
May 11, 2005 04:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.