WebFaction
Community site: login faq

I've lost my root password for my private MySQL instance. How can I recover it?

asked 19 Dec '14, 23:51

maryh
1.3k7
accept rate: 35%


  • First, open your crontab and comment out the line that starts your mysql instance. This is to prevent mysql from starting while you do the rest of the steps.

  • Stop your MySQL instance.

  • In your home directory, create a file called "mysql-ini". In that file, add the following two lines:

    UPDATE mysql.user SET Password=PASSWORD('<newpassword>') WHERE User='root';

    FLUSH PRIVILEGES;

where <newpassword> is the password you want to use.

  • Start MySQL with the following command:

    mysqld_safe --defaults-file=/home/<your_username>/webapps/<name_of_your_mysql_app>/etc/my.cnf --init-file=/home/<your_username>/mysql-init > /dev/null 2>&1 &

This will start MySQL and set the root password.

  • Delete mysql-init.

  • Stop MySQL.

  • Restart MySQL normally.

  • Uncomment the line previously disabled in your crontab.

You should now be able to login as root with your new password.

permanent link

answered 20 Dec '14, 00:05

maryh
1.3k7
accept rate: 35%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×168
×45
×7

question asked: 19 Dec '14, 23:51

question was seen: 1,872 times

last updated: 20 Dec '14, 00:05

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM