Find the answer to your Linux question:
Results 1 to 4 of 4
I am getting an access denied error trying to log in with the mysql root user when I use the correct password. I know it is the correct password as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jan 2012
    Location
    Ohio
    Posts
    175

    MYSQL error - access denied to root user


    I am getting an access denied error trying to log in with the mysql root user when I use the correct password.

    I know it is the correct password as it is used in a cron job that ran this morning. I am getting the "access denied for user 'root'@'localhost' (using password: YES) error. I know it is the correct password as I mentioned, and I know I can reset the password by stopping the mysql daemon and logging in by skipping grant tables, but this is a production server that houses several clients' sites. I would rather not take them down. Does anyone have any other ideas? I tried using phpmyadmin as well, but not luck.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,444
    Does this cron use root, root@localhost, root@127.0.0.1 or something else as mysql user?
    This does make a difference.
    You must always face the curtain with a bow.

  3. #3
    Linux Newbie
    Join Date
    Jan 2012
    Location
    Ohio
    Posts
    175
    root@localhost
    the exact command is /usr/bin/mysqldump --all-databases -u root -p<mypassword> | gzip -c > /home/db_backup/mysqlbackup.sql.gz

    Interestingly, I just tried to run the exact command as the cron job that ran fine at 2 am and I get the access denied error

    I think I may have to do the whole reset process

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jan 2012
    Location
    Ohio
    Posts
    175
    Got it fixed, but was really weird. Didn't take the first couple of times I reset it. Had to end up doing it 3 times. Third time around I had to run the service mysqld stop command after running pkill mysqld_safe and the started mysqld back up and it worked. Very strange

    For anyone who may need to do this in the future (on CentOS):
    as root:
    service mysqld stop
    mysqld_safe --skip-grant-table& (incidentally, don't forget the & as no commands you run will work)
    mysql -u root mysql
    ***you now should have a mysql> prompt*****
    UPDATE user SET password=PASSWORD("newpassword") WHERE user="root"; -notes: the " " needs to be around your password and root and don't forget the ;
    FLUSH PRIVILEGES;
    exit
    *****you should now be back at regular terminal prompt****
    pkill mysqld_safe
    service mysqld stop
    service mysqld start

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •