Only root can login mysql

Discussion in 'Server Operation' started by satimis, Sep 26, 2008.

  1. satimis

    satimis Member

    Hi folks,


    Having tried > 2 hours without a solution. Users can't login Mysql, passwords being correct.


    Steps performed as follow;

    $ mysql -u user -p
    Code:
    Enter password: some_password
    ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
    
    $ sudo /etc/init.d/mysql start
    Code:
    Password:
    Starting MySQL database server: mysqld already running.
    
    $ mysql -uroot -p
    Code:
    Enter password:
    Welcome to the MySQL monitor.  Commands end ....
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO user@"%"
        -> IDENTIFIED BY 'some_password' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.11 sec)
    
    mysql> exit
    Bye
    
    $ mysql -u user -p
    Code:
    Enter password: some_password
    ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
    

    $ sudo /etc/init.d/mysql start
    Code:
    Starting MySQL database server: mysqld already running.
    
    $ mysql -u user -p
    Code:
    Enter password:
    ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)
    
    Please help. TIA


    B.R.
    satimis
     
  2. falko

    falko Super Moderator Howtoforge Staff

    You must either run
    Code:
    FLUSH PRIVILEGES;
    on the MySQL shell after the GRANT command or restart MySQL.
     
  3. satimis

    satimis Member

    Noted and thanks


    Edit:

    First I ran;
    Code:
    mysql> GRANT ALL PRIVILEGES ON *.* TO user@"%"
             -> IDENTIFIED BY 'mypassword' WITH GRANT OPTION
    	 -> FLUSH PRIVILEGES;
    
    It did not solve the problem. Then I ran;

    Code:
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
             -> IDENTIFIED BY 'mypassword' WITH GRANT OPTION
    	 -> FLUSH PRIVILEGES;
    
    Problem solved. User can login MySQL.


    B.R
    satimis
     
    Last edited: Sep 27, 2008
  4. falko

    falko Super Moderator Howtoforge Staff

    The GRANT and the FLUSH commands are two separate commands (i.e., you must use a ; after each command) - you ran them as one command...
     
  5. satimis

    satimis Member

    Hi falko,


    Sorry I made a mistake on my previous posting. They were 2 commands. I just referred to the notice.


    B.R.
    satimis
     

Share This Page