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!
yea, i cant believe i let that slip, first off your trying to connect to a account that does not exist, and 2 to create a user, correct me if im wrong, you have to be connected as root user
You aren't encrypting the password so you won't be able to log in. MySQL will automatically encrypt the password you are trying to connect with and will end up comparing it to an unencrypted password.
i was about to suggest the encrypt problem too, twig beat me to it, what you could've done/can do is to download mysql front (there is a linkfor it in general i think) and add a user with that, then see waht tables are affected and how.
btw, you have to use password(); to encrypt your passwords when you adda user, when you connect, there is no need to it cos mysql will do it for you.
I have encrypted my password in the Insert command but when I try to connect I still get access denied.
Funny thing: If I don't use a password i.e. creating a user with an empty passowrd , I pass the mysql_connect function but fails on the mysql_select_db function with an access denied error
You will fail to select a database because you may not have set the permissions for that user on that database. Unless you keep us uptodate on the state of your code we will not be able to help you.
I ask again:
And your code is? And you've followed the directions in the documentation?
I have posted my code in one of my previous posts.
The user is entered successfully to the right place with ALL of the privilages.
the new record looks exatcly like a different record that works fine (except of the user name all is the same) so I can't see why can't I log on with the new user...
You posted code from before you made changes to encrypt the password, without you showing your SQL statements as you go along how are we supposed to help you work out what is going wrong?
Maybe if you showed us a dump of the data as well so we could test it locally? Without this sort of information we are just scratching around in the dark and will have trouble helping you solve this problem.
agian..get mysql front, just for the sake of it, add a new user with it, see what happens, if you can connect with that user then you will know your code is messing up somewhere.
Doesn't look like you reloaded the grant tables before trying to connect as the new user. You really, really, really should carefully read: http://www.mysql.com/doc/en/Adding_users.html
I have found all of the problems I've mentioned thus far via that page, you should also RTFM.
Why use INSERT with the mysql.user table?
It would be a lot easier just using grant, you dont have to worry about the password encoding nor locking and rehashing and such..
GRANT SELECT,INSERT,UPDATE ON * TO 'username'@'localhost' IDENTIFIED BY 'password'