Page 1 of 2
cannot connect t mySQL server using username & password
Posted: Wed Jun 19, 2002 7:59 am
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?
Well...
Posted: Wed Jun 19, 2002 8:33 am
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"?
Posted: Wed Jun 19, 2002 8:39 am
by b16a1
I'll try the first, because we're using the 3306 port... that shouldn't be the problem...
Posted: Wed Jun 19, 2002 9:06 am
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:
(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
Posted: Wed Jun 19, 2002 9:07 am
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?
Posted: Wed Jun 19, 2002 9:13 am
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
Posted: Wed Jun 19, 2002 9:18 am
by twigletmac
Have you tried logging in via the command line or only tried to access the database server via PHP?
Mac
Posted: Wed Jun 19, 2002 9:18 am
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

)
Posted: Wed Jun 19, 2002 9:22 am
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
Posted: Wed Jun 19, 2002 9:25 am
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
Posted: Wed Jun 19, 2002 9:29 am
by b16a1
has been done ... yes...
problem persisted afterwards

Posted: Wed Jun 19, 2002 9:35 am
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
Posted: Wed Jun 19, 2002 9:37 am
by b16a1
it is...
the user was installed that way, because eventually the dbase will be accessed from another server...
Console login?
Posted: Wed Jun 19, 2002 9:44 am
by tuXXer
Can you connect to the MySQL-server with:
mysql -u <username> -h <hostname> -P <port> -p
????
Posted: Wed Jun 19, 2002 9:45 am
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