Mailinglist Archive: opensuse (4343 mails)

< Previous Next >
Re: [SLE] mysql root permission denied
  • From: Kevin Donnelly <kevin@xxxxxxxxxx>
  • Date: Thu, 7 Nov 2002 17:48:03 +0000
  • Message-id: <200211071748.03520.kevin@xxxxxxxxxx>
On Thursday 07 November 2002 8:55 am, sjb wrote:
> > /usr/bin/mysqladmin: connect to server at 'localhost' failed
> > error: 'Access denied for user: 'root@localhost' (Using password: NO)'

My understanding of the problem (and please, someone, correct me if I'm wrong)
is that MySQL views the local physical machine as two virtual machines -
localhost, and hostname (as you can see if you look at the user table of the
mysql database). The normal command that is recommended to set the password
only changes the hostname record, but when you then go to log in, the
localhost one is used by default. That doesn't have a password in the
record, so it is rejected. But it won't accept a blank password either,
since one has been set for that user on the hostname twin! So you're stuck.

What you need to do is specify localhost as the login source, as follows:
mysql -u root -h localhost -p
then give your password. Hopefully that should get you in. (If it does not,
your password is incorrect, and we will need to do another Cunning Trick to
sort that out.)

Once there, run:
update user set password=password("mypassword") where user="root";
then:
delete from user where user="";
(that's a double quote followed by another double quote).
Then exit mysql, and run:
mysqladmin -u root reload
and give your password - this will reload the grant tables you just amended.
Then run:
mysql -uroot -p
and give your root password - you should then be logged in as root.

You have just set BOTH hostname and localhost to the SAME password, so you
don't need to specify localhost from now on. You have also got rid of the
blank test user, which is a security risk.

This comes up so often I think it should be put on the SuSE support db
somewhere. Something like:
Immediately after install of MySQL, run:
mysql
and it will allow you to log in without a password. Now set the password for
root by running:
update etc, as above.

This would save an awful lot of hair-pulling.

HTH

Kevin


< Previous Next >
References