How to connect to the MySQL database in the mode without checking the password and change the lost password to a new one?
1 answer
To change the password for the superuser root, you need to connect to the MySQL server in the absence of a password check, change the password, start the server in the normal mode, connect using the new password. To do this, you need to complete a few steps:
- Stop mysql
To do this, run the command in the command line:net stop mysql
After stopping the server, the console window is "in standby mode", without closing this window, open a new one; - Go to the directory where MySQL was installed using the command: cd c: \ <path to the bin folder> After the current position in the console points to the bin folder. Execute the command:
mysqld --skip-grant-tables --user=root &
As a result of the command, the server was launched in the mode in which you can connect to it without using a password - Run the mysql client:
mysql -u root - Execute sql query:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
where newpwd is the new password - Apply changes:
FLUSH PRIVILEGES;Further changes are saved and the root user has a new password. To log in to MySQL in standard mode, you need to start the service command:net start mysqlHowever, an error may occur when starting the service in this case, restart the computer and connect to MySQL with a new password.
|