cannot connect t mySQL server using username & password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

cannot connect t mySQL server using username & password

Post by b16a1 »

well... what the topicname says...

I can connect to the mySQL server from PHP, w/o using a username and a password, or using just a username....

either way: I'm logged in as an anonymous user (we added it as a temp)

Problem is: when I connect using the username and password, I keep getting access denied... and after 3 days I'm getting kinda bold... :(

ow... I'm doing this:
$link = mysql_connect("localhost","username","password");

and this is what I get:

Warning: Access denied for user: 'SLH@localhost' (Using password: YES) in path/to/file/select.php on line 2

Warning: MySQL Connection Failed: Access denied for user: 'SLH@localhost' (Using password: YES) in path/to/file/select.php on line 2


anybody have any idea as to what might cause this?
tuXXer
Forum Newbie
Posts: 4
Joined: Wed Jun 19, 2002 8:10 am

Well...

Post by tuXXer »

The message means that the user don't have the permissions to connect to the MySQL server

There a two solutions:

1. You have enabled sql-safe-mode in the php.ini therefore username and password would be ignored => disable it
2. The used username and/or password and/or host are incorrect. Why do you don't enter the port or do you use the standard port "3306"?
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

I'll try the first, because we're using the 3306 port... that shouldn't be the problem...
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

I had a similar problem, it could help you.

You have to know that, even though the USER table in the MYSQL db gets updated with a user and password when u add a new user, the priviledge system does not recognize that user rigth away, and thus forbids him to login. What u need to do after every time u add a new user is, either:

1) run this MySQL command:

Code: Select all

FLUSH PRIVILEGES;
(this will apply the changes made in order to allow to log in with the new user)

2) or STOP and then RESTART your MySQL server


Eug
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

unfortunately safe mode was already off...
and we're still completely in the dark :(


But at least it's a server prob, since it's not accesible from the server itself (I'm going over the web, constantly uploading the file to a remote server. I'm working with the guy maintaining it, so he's checking too... but no luck so far...)

anybody?
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

Try to login manually to the MySQL server with the same user and password. If it doesnt work, then the problem is probably the one I described in my earlier post, so just follow what I wrote there and u should be fine.

Eug
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried logging in via the command line or only tried to access the database server via PHP?

Mac
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

you're partially correct.... but it just doesn't work...

port cannot be the problem (tried both possibilities w/ and w/o port)
the safe mode was already off...

but we're looking into the password thing right now. It seems for some reason it doesn't get saved in the database...
(that's what the guy is telling me, don't shoot me ;) )
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

twigletmac: we're trying to acces on two ends:

me through php over the web
colleague directly, I think through the mysqladmin, but can't be sure (it's a 90minute drive up there, I'm not checking ;) )

both won't work correctly I believe
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

The password should be saved in a encrypted form in the USER table, so thats why it looks different than the actual password. The password() function in MySQL is normally used to encrypt a password before it is stored in the USER table.

Did u try stoping and restarting the server??????? It could be an easy and fast solution.

Eug
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

has been done ... yes...

problem persisted afterwards :(
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

Ok,

than if u can not log in manually from the command line with that user, than there is most probably a problem with the way the user was created.

U need to check that the user is allowed to login to mysql from ANY host location. This can be seen in the USER table, under the host field; there should be a % sign.

eug
b16a1
Forum Newbie
Posts: 9
Joined: Wed Jun 19, 2002 7:59 am
Location: netherlands

Post by b16a1 »

it is...

the user was installed that way, because eventually the dbase will be accessed from another server...
tuXXer
Forum Newbie
Posts: 4
Joined: Wed Jun 19, 2002 8:10 am

Console login?

Post by tuXXer »

Can you connect to the MySQL-server with:

mysql -u <username> -h <hostname> -P <port> -p

????
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

ok good.

One other think I can think of is to check in the DB table of MySQL. If the user u created is not there, just add an entry that will specify the database that this user should be alloed to use and what priviledges he has on it.

eug
Post Reply