What do you do if you forget your password

  • 2020-11-20 06:17:30
  • OfStack

First, let me introduce windows mysql forget password solution.

The actual operation under Windows is as follows

1. Close the running MySQL.

2. Open the DOS window and go to the mysql\bin directory.

3. Enter mysqld -- ES17en-ES18en-ES19en enter. If you don't get a prompt, you're right.

4. Open another DOS window (because the previous DOS window has stopped moving) and go to the mysql\bin directory.

5. Enter mysql enter. If successful, the MySQL prompt will appear >

6. Connect to permission database > use mysql; ( > It's an existing prompt. Don't forget the semicolon at the end.)

6. Change password: > update user set password=password("520") where user="root"; (Don't forget the last semicolon.)

7. Refresh permissions (required steps) > flush privileges;

8. Quit > \q

9. Log out of the system, enter again, open MySQL, use the user name root and the new password just set 123456 to log in.

Step 1

C:\Documents and Settings\Administrator > cd D:\web\www.php100.com\Mysql\MySQL Se
rver5. 5 \ bin
C:\Documents and Settings\Administrator > d:
D: \ web \ www php100. com \ Mysql \ MySQL Server5. 5 \ bin > mysqld --skip-grant-tables

Step 2

Microsoft Windows [version 5.2.3790]
Copyright 1985-2003 Microsoft Corp. All Rights Reserved.
C:\Documents and Settings\Administrator > cd D:\web\www.php100.com\Mysql\MySQL Se
rver5. 5 \ bin
C:\Documents and Settings\Administrator > d:
D: \ web \ www php100. com \ Mysql \ MySQL Server5. 5 \ bin > mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help; ' or '\h' for help. Type '\c' to clear the current input statement.
mysql > use mysql;
Database changed
mysql > update user set password=password("520") where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql > flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql > \q
Bye
D: \ web \ www php100. com \ Mysql \ MySQL Server5. 5 \ bin >

Here is the root password forgetting solution of mysql under linux

1. First verify that the server is in a secure state, that no one can arbitrarily connect to the MySQL database.

Because during the reset of MySQL's root password, the MySQL database is completely without password protection, other users can also log in and modify MySQL information at will. You can achieve a quasi-secure state of the server by closing MySQL to the external port and stopping Apache and all user processes. The safest state is to operate on the server's Console and unplug the network cable.

2. Modify the login Settings of MySQL:

# vi /etc/my.cnf

Add a sentence to the paragraph [mysqld] : ES287en-ES288en-ES289en

Such as:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables

Save and exit vi.

3. Restart mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

4. Log in and change the root password for MySQL

# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql > USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql > UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql > flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql > quit
Bye

5. Change the login Settings of MySQL back

# vi /etc/my.cnf
Delete the es372EN-ES373en-ES374en just added in the paragraph [mysqld]
Save and exit vi.

6. Restart mysqld

# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]


Related articles: