We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Mysql login from root user without password

rboudrie asked
Medium Priority
Last Modified: 2012-05-06
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".

Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.