472,133 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

How to set the root user password?

First of all, I'm not sure if I've set up root password for MySQL server or not. I was following this tutorial http://www.howtoforge.com/centos-5.1...p-ispconfig-p4 to install mysql on my CentOS 5 server.

When I run 'mysqladmin -u root password yourrootsqlpassword', I got this error message:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Then I go to MySQL prompt running ' mysql -uroot -pPassword' (Password is replaced by actual password)

When I am on MySQL prompt, I run

mysql> select user, host, password from user where user='root'; and I saw there are three root users in the user table:

Expand|Select|Wrap|Line Numbers
  1. +------+-----------+-------------------------------------------+
  2. | user | host      | password                                  |
  3. +------+-----------+-------------------------------------------+
  4. | root | localhost | *FSDFSAFEFSD124521FSDFSFZFD14584FZZFE22F |
  5. | root | li27-127  | *FSDFSAFEFSD124521FSDFSFZFD14584FZZFE22F |
  6. | root | 127.0.0.1 | *FSDFSAFEFSD124521FSDFSFZFD14584FZZFE22F |
  7. +------+-----------+-------------------------------------------+
From this output, can I say that my root user(s) already has password?

Should I have only one root user for 'localhost' and delete the other two from the user table?

Thanks!
Aug 29 '08 #1
2 3618
coolsti
310 100+
When you first install MySql on Centos (at least for Centos 4.5 and lower) I think your root does not initially have a password.

Anyway, the way I log on to mysql in a console window is as follows:

mysql -u root -p [databasename]

where the database name in the brackets is optional.

When you use the above, you are then prompted for your password. This is easier if your password has special symbols in it which would maybe confuse putting it after the -p on the mysql command line.

Your three rows for the root user are for root "coming from" three different places. The first and last are probably equivalent, as 127.0.0.1 should be the same on your machine as "localhost". Be careful in deleting any of them, if you don't really know which one should be deleted! I am not sure where mysql thinks you are "coming from" when you log on via a console window.

And yes, the fact that there are entries in the password field does indicate that there is a password set up for the root user in all three cases. This is not the actual password that you would type in, but an encrypted version that you get when you use the mysql password() command.

I cannot remember the command, but you can set or reset your password from within mysql in the console window. Take a look at the documentation. Something like set password etc.
Aug 29 '08 #2
Atli
5,058 Expert 4TB
I cannot remember the command, but you can set or reset your password from within mysql in the console window. Take a look at the documentation. Something like set password etc.
Expand|Select|Wrap|Line Numbers
  1. SET PASSWORD FROM 'user'@'host' = PASSWORD('newPassword');
  2.  
Just for the record :)

P.S.
I changed the thread title to make it a little clearer.
Please avoid using phrases like "please help me" in thread titles.
Check out the Posting Guidelines for tips on how to make good thread titles.

Thanks.
MODERATOR
Aug 30 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Adam Smith | last post: by
reply views Thread by damontimm | last post: by
4 posts views Thread by Bob | last post: by
1 post views Thread by mattsql22 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.