0

For some reason, when creating a MySQL user with empty password, it only allows connections if the user has the same name as a system user (Ubuntu Server 10.04, MySQL version 5.1.41). According to everything I have read so far, MySQL users ought to be completely separate from the system user accounts, so I'm not sure how to explain what's going on.

Am I doing something wrong? Is there some settings somewhere that affects this?

(Additional info: I'm setting this up to only allow connections from the local network; some of the tools I'm using on a project require a user without a password.)

This seems likely to be a duplicate, though when I searched I couldn't find any previous question about this issue. If the same question HAS been asked before, I apologize.

1 Answer 1

-1

here is something i found in mysql docs.

When you assign an account a nonempty password using SET PASSWORD, INSERT, or UPDATE, you must use the PASSWORD() function to encrypt the password, otherwise the password is stored as plaintext. Suppose that you assign a password like this:

mysql> SET PASSWORD FOR
    -> 'username'@'localhost' = 'mypass';

The result is that the literal value 'mypass' is stored as the password in the user table, not the encrypted value. When user attempts to connect to the server using this password, the value is encrypted and compared to the value stored in the user table. However, the stored value is the literal string 'mypass', so the comparison fails and the server rejects the connection with an Access denied errorFirst have a user name (other than system name) with some password.

So have a user name of your choice with some passowrd and then use PASSWORD() function to set an empty password. The use of the function can be seen here.

3
  • Thanks for the answer, but setting a password to PASSWORD('') has the same effect as not adding "IDENTIFIED BY <PASS>" when you create the user. I just tried with a user whose name is different than the system user, and again mysql refuses the connection.
    – Joseph
    Jan 28, 2011 at 18:29
  • u are not going to set any password using this function. just get the hash value of "" using this function. and then use <mysql> CREATE USER 'username'@'localhost' -> IDENTIFIED BY PASSWORD '*90E462C37378CED12064BB3388827D2BA3A9B689'; where this hash value is the one you got using PASSWORD() on blank.
    – ayush
    Jan 28, 2011 at 18:43
  • actually, I created the user and then did 'set password for "<user>"@"%" = PASSWORD("")'; another test with 'select PASSWORD("")' shows that the result is null . So I'm afraid this isn't going to solve my problem, at least on my system.
    – Joseph
    Jan 28, 2011 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.