mysql password problem again

Discussion in 'Server Operation' started by kwickcut, Mar 9, 2012.

  1. kwickcut

    kwickcut Member HowtoForge Supporter

    after installing ubuntu perfect server 10.04
    Code:
    http://www.howtoforge.com/perfect-server-ubuntu-10.04-lucid-lynx-ispconfig-3
    and everything was up and running after a few small tweaks with the email and ftp server i have just run up against a lost password for mysql. everything was working just fine on Wednesday but when i went to log into phpmyadmin as root yesterday i could not gain access. for some reason the root password has changed again for the second time once on the old server and once on the new server.

    when trying to log into mysql command line i used this
    Code:
    root@server1:~# mysql -u root -p
    
    and this is the output
    Code:
    root@server1:~# mysql -u root -p
    Enter password:my password used during setup 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    root@server1:~#
    
    so i am tried to change the root password for mysql i run this command

    Code:
    root@server1:~# sudo /etc/init.d/mysql stop
    
    and this is the output of said command

    Code:
    root@server1:~# sudo /etc/init.d/mysql stop
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service mysql stop
    
    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the stop(8) utility, e.g. stop mysql
    root@server1:~#
    
    i have searched google and have not come across an answer to this issue has anyone had this happen and how did you overcome it



    kwick
     
    Last edited: Mar 9, 2012
  2. falko

    falko Super Moderator Howtoforge Staff

    You can ignore this - Ubuntu wants you to use
    Code:
    service mysql stop
    instead of
    Code:
    /etc/init.d/mysql stop
    but both commands do the same.

    Does
    Code:
    mysql -u root -p[I]rootmysqlpassword[/I]
    work? Please note that there's no space between -p and rootmysqlpassword.
     
  3. kwickcut

    kwickcut Member HowtoForge Supporter

    this is the output of mysql -u root -prootmysqlpassword i have tried every password that i have ever used and none work.
    Code:
    root@server1:~# mysql -u root -pmyrootpassword
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    root@server1:~#
    
     
  4. falko

    falko Super Moderator Howtoforge Staff

  5. kwickcut

    kwickcut Member HowtoForge Supporter

    i dont know if this is correct but this is what i am getting

    Code:
    root@server1:~# service mysql stop
    stop: Unknown instance:
    root@server1:~# mysqld_safe --skip-grant-tables
    120311 23:17:01 mysqld_safe Logging to syslog.
    120311 23:17:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    mysql --user=root mysql
    update user set Password=PASSWORD('mynewrootpassword') where user='root';
    flush privileges;
    exit;
    
    i then stopped mysql and restarted it

    Code:
    service mysql stop
    service mysql start
    nothing changed i still can not log in
     
  6. falko

    falko Super Moderator Howtoforge Staff

    Can you check your mysql.user table if there's a user called root?
     
  7. kwickcut

    kwickcut Member HowtoForge Supporter

    i have searched and can not find the command to list mysql.user


    kwick
     
  8. kwickcut

    kwickcut Member HowtoForge Supporter

    update i have run this command
    Code:
    root@server1:~# cat /usr/local/ispconfig/server/lib/mysql_clientdb.conf
    
    and this is the output
    Code:
    root@server1:~# cat /usr/local/ispconfig/server/lib/mysql_clientdb.conf
    <?php
    
    $clientdb_host                  = 'localhost';
    $clientdb_user                  = 'root';
    $clientdb_password              = '1967mypassword';
    now even with this info i can not log into phpmyadmin of mysql database on the server through command line

    any thoughts
     
  9. TiTex

    TiTex Member

    this should have been worked , i've just tested it on a virtual machine

    Stop the MySQL Server.
    Code:
    sudo /etc/init.d/mysql stop
    Start the mysqld configuration.
    Code:
    sudo mysqld --skip-grant-tables &
    Login to MySQL as root.
    Code:
    mysql -u root mysql
    Replace YOURNEWPASSWORD with your new password!
    Code:
    UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root';
    FLUSH PRIVILEGES; 
    exit;
    if you still can't solve your problem i would suggest to remove mysql server and install it again , if you have some databases that needs to be backed up you can copy the folder where the mysql data is stored to somewhere else and after you installed it again copy back just the databases you need , i think they should be in separate folders in the folder tree.
     
    Last edited: Mar 15, 2012
  10. falko

    falko Super Moderator Howtoforge Staff

    Just start MySQL as follows:

    Code:
    mysqld_safe --skip-grant-tables
    Then do this:
    Code:
    mysql
    Code:
    use mysql;
    SELECT * FROM user;
    Does the last command show a record where the user is root?
     
  11. kwickcut

    kwickcut Member HowtoForge Supporter

    thanks but i was unable to log in see output below

    Code:
    root@server1:~# mysqld_safe --skip-grant-tables
    120316 11:41:37 mysqld_safe Logging to syslog.
    120316 11:41:37 mysqld_safe A mysqld process already exists
    root@server1:~# mysql
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    root@server1:~# use mysql;
    No command 'use' found, did you mean:
     Command 'muse' from package 'muse' (universe)
     Command 'uae' from package 'uae' (multiverse)
    use: command not found
    root@server1:~# SELECT * FROM user;
    SELECT: command not found
    root@server1:~#
    
     
  12. falko

    falko Super Moderator Howtoforge Staff

    Please kill any other MySQL processes and try again.
     

Share This Page