Advertisement: Linux VPS for $4/month - based on OpenVZ, credit card accepted, automatic setup.
+ Post New Thread
Results 1 to 2 of 2

Thread: How to reset MySQL password via Linux command line

  1. #1
    Administrator Fli's Avatar
    Join Date
    Mar 2013
    Posts
    2,406
    Post Thanks / Like
    Blog Entries
    1

    How to reset MySQL password via Linux command line



    You will learn how to change and reset mysql password in Linux

    Your mysql password can be: blank (empty, just hit Enter button) it can be also your default ssh login password, root, admin, test

    if MySQL password is unknown, you can reset it easilly. Before reset, make sure if you are using any hosting control panel that you know how to change mysql root password in this control panel before doing reset. For resetting mysql root password, follow these steps:


    How to reset

    Stop mysql + start mysql in safe mode + Login to mysql without password

    /etc/init.d/mysqld stop
    mysqld_safe --skip-grant-tables
    Then it will probably hang on message "mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql". So start new SSH session while keeping old one open.

    In new SSH session execute:
    mysql --user=root mysql
    update user set Password=PASSWORD('YourNewMysqlPassword') where user='root'; flush privileges; exit;/etc/init.d/mysqld start
    Source: http://instantcpanelhosting.com/knowledgebase/2/MySQL-password-how-to-reset-it.html

    If this dont works, you can also create a php file as a root via command line (vi reset.php) and put this code in it: https://github.com/lxcenter/hypervm/blob/master/hypervm-install/reset-mysql-root-password.phps ; after that, run by command: php reset.php)

    How to change password

    mysqladmin -u root -p'oldpassword' password newpassword
    then enter your present password and hit Enter key

  2. #2
    Administrator Fli's Avatar
    Join Date
    Mar 2013
    Posts
    2,406
    Post Thanks / Like
    Blog Entries
    1


    Is this useful / helpfull? Yes | No
    If above process to reser mysql root password did not worked, my client adviced also this one and used these commands:
    Code:
    mysqld_safe --skip-grant-tables &
    mysql -u root
    use mysql;
    update user set password=PASSWORD(“PASSWORD”) where User=’root’; flush privileges;
    this just change the users password, but I couldnt login to 'root'@'localhost' so with this I could succesfully remove the password:

    Code:
    mysqld_safe --skip-grant-tables &
    mysql -u root
    use mysql;
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password';
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
    It changes [email protected] pass, now i dont have problem

    --------------

    Do you have any experience yourself? Or another ways on how to reset password?

    ---

    To change password, not reset it, one do: mysqladmin -u root -p'oldpassword' password newpass

+ Post New Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam