Both mysql and mysqladmin get user info for login purposes from the same place: the mysql.user table.

Mysql doesn't have a root password set by default after installation. It's very easy to overlook this and not set a password. One might think that the user you're logging into mysql with will be the same as the unix account you're logged in through, but that is only the default and you can, of course, override that by specifing -u. So people often forget to set a root password, thinking you have to be logged into unix as root in order to log in to mysql as root, but you don't. I think this is a source of some confusion in general. I've made that mistake :-(

When you set the password, did you do it by using GRANT... or by UPDATING the user table directly? GRANT will automatically flush privileges, but altering the user table directly doesn't... which is fine, you just have to say FLUSH PRIVILEGES for the changes to take effect.

So you could say
UPDATE mysql.user SET password=password('mysekretpassword') WHERE user='root';
FLUSH PRIVILIGES;


And that should do it.

Good luck!


Ralph McCarthy wrote:


Michael:

You were correct. My problem was that I had set a password for mysql but didn't realize that I had successfully done so (newbie confusion). I can now create a database. Unfortunately, there is an additional issue: it appears as though I didn't set a password for mysqladmin (or I did so inadvertently and am unaware of what that password is) because when I type the following at the prompt:

mysqladmin -u root -p

MySQLAdmin seems to start up without asking for my password:

/usr/local/mysql/bin/mysqladmin Ver 8.40 Distrib 4.0.17, for apple-darwin6.8 on powerpc
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
...


Shouldn't it request my password? Perhaps this just means that I did set the password for both mysql and mysqladmin after installation. What should I do?

Thanks for your help.

Ralph


On Wednesday, January 7, 2004, at 01:24 PM, Michael Stassen wrote:



Ralph McCarthy wrote:


Hi:
I've just installed MySQL on Mac OS X 10.2.8. I'm unable to create a database. When I try to do so, I get the following error message:


I have the same setup.

mysql> CREATE DATABASE MYDATABASE;
ERROR 1044: Access denied for user: '@localhost' to database 'mydatabase'


See #3 below.

I suspect that the problem may be that I never set the password for mysqladmin correctly (perhaps I didn't set it at all).
When I attempt to set it using this command:
mysqladmin -u root -h localhost password <password>
I get this message:
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: '[EMAIL PROTECTED]' (Using password: NO)'


See #1 below.

Please help. Thanks in advance.
Ralph


1) The command

mysqladmin -u root -h localhost password <password>

fails because [EMAIL PROTECTED] already has a password which you didn't supply. I expect this is because you've already run

mysqladmin -u root password <password>

to set the password. Once [EMAIL PROTECTED] has a password, you need to run mysqladmin like this:

mysqladmin -u root -p <command>

The -p indicates you need to suppply the password, so you'll be prompted for it.

2) If you don't know what you set as the password for [EMAIL PROTECTED], see <http://www.mysql.com/doc/en/Resetting_permissions.html>.

3) The error message indicates you are logged in as the anonymous user (username = '') who has no rights (except to the test db). You probably tried just `mysql`. Instead, you should use

mysql -u root -p

to indicate you wish to log in as [EMAIL PROTECTED] and be prompted for the password. Once logged in, you might want to get rid of the anonymous user, and set yourself up as a normal user.

Michael


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]







-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to