Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 29th, 2008, 03:36 AM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default 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:
Quote:
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!

Last edited by Atli; August 30th, 2008 at 08:17 PM. Reason: Replaced the quote with [code] tags to preserve the formatting.
Reply
  #2  
Old August 29th, 2008, 06:22 PM
Needs Regular Fix
 
Join Date: Mar 2008
Posts: 305
Default

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.
Reply
  #3  
Old August 30th, 2008, 08:21 PM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,783
Default

Quote:
Originally Posted by coolsti
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
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles