Advertisement: Linux VPS from $4/month - contact support for custom offer.
+ Post New Thread
Results 1 to 2 of 2

Thread: How to reset MySQL password via Linux command line

  1. #1
    Administrator
    Join Date
    Mar 2013
    Posts
    2,747

    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
    Join Date
    Mar 2013
    Posts
    2,747


    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 root@localhost 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

Similar Threads

  1. Replies: 1
    Last Post: 10-18-2018, 02:46 AM
  2. Replies: 0
    Last Post: 08-31-2017, 01:55 PM
  3. Replies: 0
    Last Post: 10-05-2013, 01:34 PM
  4. Replies: 0
    Last Post: 09-29-2013, 03:44 PM
  5. Replies: 0
    Last Post: 07-01-2013, 06:30 PM

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