Har du någonsin glömt din MySQL för att rota lösenord? Det är en av den saker som händer precis illviljan de talrika försiktigheterna en styrkatake. Som ett resultat låsas du ut ur din databasserver. Du kan inte skapa nya databaser och lämnas med lite kontrollerar över det statligt av din databasserver. I sådan lägen som vet hur man återvinner, rota tar fram till din databasserver kommer i behändigt. Är så här vad du kan göra för att nollställa lösenordet för rotaanvändaren i MySQL på både Windows och Linux.
Windows användare:
Inloggning till din server som administratören. Döda den MySQL serveren, om den är rinnande. För att göra detta behöver du Windows servar chefen, så klicka på Starta menyngå därefter till, Kontrollbord, därefter till Administrativt bearbetar, och valt Servar. Här sök efter den MySQL serveren och stoppa den. Om det inte listas där och, MySQL är kassalådaspring det hjälpmedel att MySQL inte är rinnande som ett tjänste-. Isåfall behöver du att ladda uppgiftschefen som du bör tar fram genom att använda den nyckel- kombinationen av Ctrl+Alt+Del. Döda nu den processaa MySQLen.
Med det MySQL processaa som stoppas dig, behöv att tvinga en ändring av lösenord på MySQL genom att använda en kombination av UPPDATERING och SPOLNING alternativ. Så barkassen din favorit- textredaktör och skapar ett nytt sparar. Skriv in efter texten in i spara som byter ut ”NewMySQLPassword” med ditt nya lösenord:
UPPDATERA mysql.user FASTSTÄLLDA Password=PASSWORD (” NewMySQLPassword”) VAR User=' rotar';
SPOLNINGEN PRIVILEGIERAR;
Vad första fodrar, är att den uppdaterar värdera av sätta in ”lösenord” i bordlägga mysql.user för användaren ”rotar” ”NewMySQLPassword”. Understödja fodrar spolningar den gammala uppsättningen av privilegierar och ser till att ditt nya lösenord används överallt. Räddning denna text som C:\mysql _reset.txt.
Därefter behöver du att starta din MySQL server som passerar denna för att spara som en konfigurationparameter. Barkass ett slutligt, genom att gå till Starta menyn, därefter till Körning, och skriva därefter cmd och hiten skriver in. Skriv in nu efter befalla:
C:\mysql\bin\mysqld - nt --init-file= C:\mysql _reset.txt
När serveren är gjord starta borttagnings spara C:\mysql _reset.txt. Din MySQL rotar lösenord bör nollställas nu. Starta nu din MySQL server om igen igen. Gå tillbaka till Windows servar chefen igen för att göra det. Din nya MySQL rotar lösenord bör fungera för dig nu.
Linux användare:
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.























{ 4 comments… read them below or add one }
OI como faįo para recuperar a senha do root do linux Kurumin
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
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
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