Web Hosting Talk







View Full Version : MySQL Passwords for root@localhost


kaz
09-06-2001, 07:30 AM
I know this has been covered at least 10 times, but I just can't find it.
What I do find is conflicting command lines for this.

MySQL on a RaQ 4. My password works fine for localhost. I have the
PHPmyadmin installed and running fine logging in as root on localhost.

Then I go to the command line. Type

>mysql -u root -p
Enter Password: mypassword

And I get this:
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)

I'm able to log into mysql when I use the -h hostname.domain.ext tag. I log
in, update the password for this root user. And I can still log in using:

mysql -h hostname.domain.ext -u root -p
Enter Password: <blank>

I'm in.

Now PHPMyAdmin won't work. Says the root@localhost has access denied.

When all this started, the web interface worked, but I couldn't log in using
the command line. Now that I was able to log in using the command line in
addition to the actual hostname, the web interface does not work and I still
can't login using localhost at the command line.

What is happening?

swissmonk
09-06-2001, 08:27 AM
You have removed the localhost privilege for user root, log in in your database with the -h option and execute this command:

grant ALTER, CREATE, DELETE, DROP, FILE, INDEX, INSERT, PROCESS, REFERENCES, RELOAD, SELECT, SHUTDOWN, UPDATE, USAGE on *.* to 'root'@'localhost' identified by 'rootpassword' with GRANT OPTION;

kaz
09-06-2001, 09:26 AM
Can you show me the exact command?

I type:
grant ALTER, CREATE, DELETE, DROP, FILE, INDEX, INSERT, PROCESS, REFERENCES, RELOAD, SELECT, SHUTDOWN, UPDATE, USAGE on *.* to 'root'@'localhost' identified by 'rootpassword' with GRANT OPTION;

I have change 'rootpassword' to my own..

I got the following error:

sh: grant: command not found

Can show me the exact command i should type?
Step by step? Thanks.

swissmonk
09-06-2001, 09:36 AM
You have to login into mysql first...

mysql -u root -p -h yourdomain.com

enter your password

then type this command (after the mysql>):

grant ALTER, CREATE, DELETE, DROP, FILE, INDEX, INSERT, PROCESS, REFERENCES, RELOAD, SELECT, SHUTDOWN, UPDATE, USAGE on *.* to 'root'@'localhost' identified by 'yourrootpassword' with GRANT OPTION;

Then you receive back:
Query OK, 0 rows affected (0.02 sec)

type:
exit

You are back in the shell and it should be ok...

kaz
09-06-2001, 10:02 AM
I have pm and email you. I like you to teach me online or help me. Thanks.