Mysql login from root user without password

Posted on 2009-02-14
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".

Question by:rboudrie
    LVL 2

    Accepted 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:


    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


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Creating and Managing Databases with phpMyAdmin in cPanel.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now