• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1500
  • Last Modified:

Mysql login from root user without password

I have installed Mysq 5.0.67l on a Linux FEdora 10 box, and all is working well except one thing.  I should be able to login without specifying any password as long as I am logged into the Linux box as "root" and, in fact, it was this way when I first got the install up and running.  I have imported many databases (via mysqldump) from other systems, and now I can no longer log in without a password when logged in as "root".

1 Solution
Two ways...

Don't define the root password for MySQL

         To use SET PASSWORD on Unix,
do         this:        shell> mysql -u root
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');

With newpwd net defined, no spaces or anything.

See this for more: http://dev.mysql.com/doc/refman/4.1/en/default-privileges.html


create a .my.cnf file in your home (root) directory and put these line in it:


You can login to mysql via command line by typing mysql.  

So that only root can read this file chmod it to 600:
chmod 600 .my.cnf

rboudrieAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now