MySql Reset root password

Rédigé par M Sozezzo - - Aucun commentaire
Step by step how you can change 'root' password
 
You must have rights to stop/start services, and kill process.
 
Step 1: Stop MySql service
run: services.msc
...
 
Step 2 : Create file to reset password
You can use your password and your file name.
We use password : Pass1Word2
and file name : C:\temp\reset.txt
USE mysql;
UPDATE mysql.user SET Password=PASSWORD('Pass!Word@') WHERE User='root';
FLUSH PRIVILEGES;
 
Step 3 : Find our my.ini file
It is usually locate on 'C:\ProgramData\MySQL\MySQL Server ????\my.ini'
But, you can try to find using :
C:\ dir my.ini /s /b
You can check MySQL service's property.
...
For this sample, we use this:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
 
Step 4 : Navigate to MySql bin directory
Open command prompt there.
...
Type command :
mysqld --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.5\\my.ini" --init-file=C:\temp\reset.txt
Attention : Use double "\\" insted "\"
 
Step 5 : Open "Task Manager" and kill process "mysqld.exe"
Step 6: Start service "MySql"
By now, we have a new password.
cls
@echo off
cls
echo.
echo * * * Reset MySql password * * *
echo.
pause
echo.
echo Stop MySql Service
echo.
sc stop MySql
echo.
pause
echo.
echo Kill mysqld.exe
echo.
taskkill -f -im mysqld.exe
echo.
pause
echo.
rem dir "C:\ProgramData\MySQL\MySQL Server 5.5\my.ini"
echo.
echo Run MySqlD
echo.
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld"   --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" --init-file=C:\Temp\reset.txt
echo.
pause
echo.
echo Start MySql Service
echo.
sc start MySql
echo.
pause
echo.
echo Try to connect
echo.
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe" "--defaults-file=C:\Program Files\MySQL\MySQL Server 5.5\my.ini" "-uroot" "-p"
echo.
cd\temp
echo.
** Attention : Make sure all file are ANSI

Les commentaires sont fermés.