Home > database >  MySQL - 4 methods modify the root password
MySQL - 4 methods modify the root password

Time:09-21

MySQL - modify the root password 4 methods, WINDOWS OS for
# mysql Ver 15.1 Distrib 10.4.11 - MariaDB, for osx10.15 (x86_64) using readline # 5.1


Method 1: use the SET PASSWORD command

Log in first MySQL,

Format: mysql> Set the password for user name @ localhost=password (' new password '); Applicable to # (OS)
Example: mysql> Set the password for root @ localhost=password (' 123 ');



Method 2: use mysqladmin

Format: mysqladmin -u username -p
old password password the new password
Example: mysqladmin uroot - p123456 password 123



Method 3: use the UPDATE directly edit user table

Log in first MySQL,

Mysql> The use of mysql;

Mysql> Update the user set the password=password (' 123 ') where the user='root' and the host='localhost'

Mysql> Flush privileges;



Method 4: forget the root password, it can be

In Windows, for example:

1. Shut down the running MySQL service,

2. Open a DOS window, turn to mysql \ bin directory,

3. Input mysqld - skip - grant - tables carriage return, - skip - grant - the meaning of the tables is the time to start the MySQL service skip permissions table certification,

4. To open a DOS window (because the DOS window has been can't move just now), turn to mysql \ bin directory,

5. Enter the mysql enter, if successful, will appear the mysql prompt & gt; ,

6. Connect the access database: use mysql; ,

6. Change password: update the user set the password=password (" 123 ") where the user="root"; (don't forget to add a semicolon),

7. Refresh the permissions (must) : flush privileges; ,

8. Quit quit,

9. Cancellation of system, and then, using the username root and have just set a new password login, 123

CodePudding user response:

Thanks for sharing, it is recommended that the blog

CodePudding user response:

Thanks for sharing, it is recommended that the blog
  • Related