By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

mysql allows blank username and password

P: n/a
Hi, I'm a bit of a newbie to PHP and mySQL. I'm trying to get things running
on my W2K machine.

I'm having a problem using the mysql_connect() function (although the
problem's probably rooted in mysql). When trying to log in via PHP with the
code "$link = mysql_connect("localhost", "phil", "pwpass123");" I get the
error...

Warning: mysql_connect() [function.mysql-connect]: Access denied for user:
'phil@localhost' (Using password: YES) in c:\inetpub\wwwroot\php\mysql.php
on line 9

The thing is that it connects ok if I leave the username and password blank.
The ones I'm using above are ones I specified in mysqladmin when I first ran
it.

Can anyone help me 1) Stop mysql accepting blank username and password
values, and 2) get it to accept my defined username and password?

Many thanks in advance,
Phil
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I would hazard a guess that you haven't granted phil the right permissions.

mysql -- user=root mysql
GRANT ALL PRIVEILEGES ON *.* TO user@localhost IDENTIFIED BY 'password' WITH
GRANT OPTION;

I would also guess that root (which is the default) doesn't have a password
set up which is why that works.

HTH.
PWT.

"Phil W" <me@privacy.net> wrote in message
news:bj************@ID-180242.news.uni-berlin.de...
Hi, I'm a bit of a newbie to PHP and mySQL. I'm trying to get things running on my W2K machine.

I'm having a problem using the mysql_connect() function (although the
problem's probably rooted in mysql). When trying to log in via PHP with the code "$link = mysql_connect("localhost", "phil", "pwpass123");" I get the
error...

Warning: mysql_connect() [function.mysql-connect]: Access denied for user:
'phil@localhost' (Using password: YES) in c:\inetpub\wwwroot\php\mysql.php
on line 9

The thing is that it connects ok if I leave the username and password blank. The ones I'm using above are ones I specified in mysqladmin when I first ran it.

Can anyone help me 1) Stop mysql accepting blank username and password
values, and 2) get it to accept my defined username and password?

Many thanks in advance,
Phil

Jul 16 '05 #2

P: n/a
A Martian named "Phil W" <me@privacy.net> telepathically imparted message
<bj************@ID-180242.news.uni-berlin.de> to us on Fri, 05 Sep 2003
05:59:23 -0500:
[snipped mysql login error]
The thing is that it connects ok if I leave the username and password
blank. [...]


Delete the "test" database and make sure that the
"root" user (in mysql) has a password.

By default, anonymous users have access to databases
that start with "test" (I think).

For your login problem, perhaps you are using the wrong
password. See if you can change it with mysqladmin.

Jul 16 '05 #3

P: n/a
"Gary Petersen" <ga*******@remove.meearthlink.invalid> wrote in message
news:pa********************************@REMOVE.MEe arthlink.INVALID...
Delete the "test" database and make sure that the
"root" user (in mysql) has a password.

By default, anonymous users have access to databases
that start with "test" (I think).

For your login problem, perhaps you are using the wrong
password. See if you can change it with mysqladmin.


Cheers Gary, I ended up going back to square one and doing just that.

Also, I think I was getting mixed up with the winmysqladmin - the username
password defined there seems to just get dropped into the my.ini file for
login, whereas I originally thought it was setting that user up too. I could
well be wrong about that though! I think I need to get one of those "for
dummies" books on mysql!
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.