Step 1 in Windows. log on to windows as an administrator. use windows service management tools or task manager to stop MySQL service 3. create a text file for a single row and save it as c: mysqlpwdhf.txt. The content is SETPASSWORDFORroot @ localhostPASSWORD (MyNewPassword); 4. open a controller
Step 1 in Windows. log on to windows as an administrator. use windows service management tools or task manager to stop MySQL service 3. create a text file FOR a single row and save it as c: mysqlpwdhf.txt. The content is set password for 'root' @ 'localhost' = PASSWORD ('mynewpassword'); 4. open a controller
Steps on Windows
1. log on to windows as an administrator
2. Use windows service management tools or task manager to stop MySQL services
3. Create a single-line text file and save it as c: mysqlpwdhf.txt,
The content is set password for 'root' @ 'localhost' = PASSWORD ('mynewpassword ');
4. Open a console window and get the doscommand prompt.
5. Assume that your MySQL main directory is C:/mysql/bin,
Run c: mysqlbinmysqld-nt -- init-file = c: mysqlpwdhf.txt,
If you are using a MySQL database server installed with the installation wizard, you need to use the service management tool to make changes,
You need to find and add the default settings file,
Then run mysqld-nt -- defaults-file = "pathmy. ini" -- init-file = c: mysqlpwdhf.txt.
6. Stop the MySQL database service and start MYSQL again in normal mode.
7. You can log on to the server normally.
Steps in Unix
1. log on to the system as root or as the user who starts the mysqld Process
2. Find and locate the file. pid that contains the Mysql service process number, which is generally possible
/Var/lib/mysql/,/var/run/mysqld/,/usr/local/mysql/data,
The file name is generally in the format of "machine name. pid. Use COMMANDS IN SHELL
Kill 'cat/mysql-data-directory // host-name.pid 'to end the mysql service process
3. Create a single-line text file, which can be named at will, for example, mysql-init,
Save it in the user's home directory ~ ,,
The file content is set password for 'root' @ 'localhost' = PASSWORD ('mynewpassword ');
4. Enable mysql with the "record" option. The specific command is mysqld_safe -- init-file = ~ /Mysql-init &,
Normally, delete the mysql-init file.
5. You can use a new password to connect to the database.
General Solution:
-Use the client interaction tool mysql to set the parameters as follows:
1. Stop the mysql service and run -- skip-grand-table -- user = root again.
Option to start the mysql service (the -- user = root option can be omitted in windows)
2. Use the client interaction tool mysql to connect to the server. shell> mysql-u root
3. Execute the following statement in the client interaction tool mysql:
Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd ')
-> WHERE User = 'root ';
Mysql> flush privileges;
4. You can use newpwd as the password to log on to the server.