Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

When I am root, "mysql" connects without a password, even though I've set one:

# mysqladmin -u root password 'whatever'
# mysql -u root -p
Enter password: (typing the 'whatever' above)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.22-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> Bye

but unfortunately this also happens...

# mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25 to server version: 4.1.22-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> 

So even though I've set the password, and it IS checked when I use "-p", it is however not necessary!?!?

share|improve this question
    
Check your .my.cnf config file for the lines user=root and password=pass. Do they exist? If so, that's why you're able to log in without a password. Deleting those lines should correct that. –  Nick Jun 11 '11 at 9:22
    
Thank you! That was it. Please answer it outside of a comment, so I can accept it and give you points :-) –  John Smith Jun 11 '11 at 9:38
2  
Cross-post: serverfault.com/q/279411/51929 –  Lekensteyn Jun 11 '11 at 9:52
add comment

closed as off topic by danlefree Aug 31 '11 at 0:33

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Check your .my.cnf config file for the lines user=root and password=whatever. These enable you to log in without a username or password. Delete those lines if you want to be prompted for a password instead.

share|improve this answer
add comment

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