Wie man ein verlorenes MySQL Wurzelkennwort zurückstellt

durch Sukrit Dhandhania auf 26. November 2008

Linux Sicherheit Windows

Hatten Sie überhaupt Ihr MySQL Wurzelkennwort vergessen? Es ist eine jener Sachen, die gerade trotz der zahlreichen Vorsichtsmaßnahmen geschieht, die, man treffen konnte. Infolgedessen sind Sie aus Ihrem Datenbankbediener heraus verschlossen. Sie können nicht neue Datenbanken verursachen und werden mit wenig Steuerung über dem Zustand Ihres Datenbankbedieners verlassen. In solchen Situationen, die Wurzel wiedergewinnen gekonnt werden, machen Sie zu Ihrem Datenbankbediener kommt in handliches zugänglich. Ist so hier, was Sie tun können, um das Kennwort für den Wurzelbenutzer in MySQL auf Windows und Linux zurückzustellen.

Windows Benutzer:

LOGON zu Ihrem Bediener als dem Verwalter. Töten Sie den MySQL Bediener, wenn er läuft. Um dies zu tun benötigen Sie Windows Kundendienstdirektor, also klicken Sie an Beginnen Sie Menü, gehen Sie dann zu Steuerverkleidung, dann zu Administrative Werkzeugeund auserwählt Dienstleistungen. Hier suchen Sie nach dem MySQL Bediener und stoppen Sie ihn. Wenn es nicht dort verzeichnet wird und MySQL ist, bis, es laufen zu lassen bedeutet, daß MySQL nicht als Service läuft. In diesem Fall müssen Sie den Aufgabe Manager laden, deren Sie zugänglich machen mit Tastenkombination sollten Ctrl+Alt+Del. Töten Sie jetzt den MySQL Prozeß.

Wenn der MySQL Prozeß gestoppt ist, Ihnen müssen Sie eine änderung von Kennwörtern auf MySQL mit einer Kombination von zwingen UPDATE und ERRÖTEN Wahlen. Stoßen Sie so Ihren Lieblingstextherausgeber aus und stellen Sie eine neue Akte her. Tragen Sie den folgenden Text in die Akte ein, die „NewMySQLPassword“ mit Ihrem neuen Kennwort ersetzt:

UPDATE mysql.user GESETZTES Password=PASSWORD (“ NewMySQLPassword“) WO User=' Wurzel';
EBENE PRIVILEGIEN;

Was die erste Linie, ist, daß es den Wert auffangene „Kennwort“ in der Tabelle mysql.user für den Benutzer „Wurzel“ „NewMySQLPassword“ aktualisiert. Die zweite Linie spült den alten Satz von Privilegien und stellt sicher, daß Ihr neues Kennwort überall verwendet wird. Außer diesem Text wie C:\mysql _reset.txt.

Zunächst müssen Sie Ihren MySQL Bediener anstellen, diese Akte als Konfiguration Parameter zu führen. Stoßen Sie einen Anschluß aus, indem Sie zu gehen Beginnen Sie Menü, dann zu Durchlaufund schreiben Sie dann cmd und Erfolg kommen herein. Tragen Sie jetzt den folgenden Befehl ein:

C:\mysql\bin\mysqld - NT --init-file= C:\mysql _reset.txt

Sobald der Bediener Löschung beginnend die Akte getan wird C:\mysql _reset.txt. Ihr MySQL Wurzelkennwort sollte jetzt zurückgestellt werden. Beginnen Sie jetzt Ihren MySQL Bediener wieder wieder. Gehen Sie zurück zu dem Windows Kundendienstdirektor wieder, das zu tun. Ihr neues MySQL Wurzelkennwort sollte für Sie jetzt arbeiten.

Linux Benutzer:

Log on to your Linux machine as the root user. The steps involved in resetting the MySQL root password are to stop the MySQL server, restart it without the permissions active so you can log into MySQL as root without a password, set a new password, and then restart it normally. Here’s how you do it. First, stop the MySQL server:

# /etc/init.d/mysql stop

Now start the MySQL server using the --skip-grant-tables option, which will run the server without loading the permissions settings:

# mysqld_safe --skip-grant-tables &

The & option at the end makes the command you have executed run as a background process. Now log on to your MySQL server as root:

# mysql -u root

It should allow you in without prompting for a password. The following steps will set the new password:

mysql> use mysql;
mysql> update user set password=PASSWORD(”NewMySQLPassword”) where User=’root’;
mysql> flush privileges;
mysql> quit

Replace “NewMySQLPassword” with your own password. Here’s what happens here. The first line selects the MySQL configuration tables. The second line updates the value of the field “Password” for the user “root” to “NewMySQLPassword”. The third line flushes the old set of privileges and makes sure your new password is used everywhere. Now, the last step is to restart the server normally and use your new root password to log in:

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
# mysql -u root -pNewMySQLPassword

Congratulations, your new MySQL root password is set and your MySQL server is ready to be used again. Remember to update all your applications to use this password if you are using it anywhere.

Related Posts:
  • How to remotely access your MySQL in a secure manner
  • How to enable the root user account in Ubuntu Linux
  • Bash one liner - how to compress, move, and extract a directory
  • How to reset the logo in Internet Explorer
  • How to install and setup Apache, MySQL and PHP in Windows
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Just enter your email address below:

    You can always opt out of this email subscription at any time.

    { 4 comments… read them below or add one }

    1 Marcos Santos 12.24.08 at 7:53 pm

    OI como faço para recuperar a senha do root do linux Kurumin

    2 xxxxxxx 05.20.09 at 8:13 am
    3 Manfred 06.10.09 at 2:25 am

    BTW the syntax above is missing a -
    There should be a double minus sign in front of the init. Do that and the commands work fine. Looking at it, its missing elsewhere too - so might be your blog s/w converting double en dash to em dash

    C:\mysql\bin\mysqld-nt -–init-file=C:\mysql_reset.txt

    4 Ross McKillop 06.10.09 at 6:05 am

    Thanks Manfred - you’re right, it did convert the double-dashes into a single dash. It’s all fixed now. Thanks again!

    Leave a Comment

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>