May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

MySQL 5.7 forget the root password

surroundings

CentOS 6.6 X86_64

background

Forget how to do root, forget to initialize MySQL generated when the random password how to do, or simply did not register that random password, do not tell me to clear all the data under data, reinitialize, of course, you have to be so wayward can also be.
Do not pull, the following is the title.

reference

Http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

operating

There are several ways in the official document, I read the next, you remember the following I said a bar, the other you try it, so good to make me no matter

Use –skip-grant-tables to start mysql server
bin / mysqld_safe –user = mysql01 –skip-grant-tables – skip-networking &

Two options are meaning –
skip-grant-tables skip authorization –
skip-networking does not allow remote network connection

Skip-networking can not, to prevent other users to connect the remote operation of the database, do not look at the actual situation. Just learn an option.

Client login
bin / mysql -uroot -p
update mysql.user set authentication_string = password (‘root’), password_expired = ‘N’ where user = ‘root’;
flush privileges;

Change the password if you still remember ALTER USER ‘root’ @ ‘localhost’ IDENTIFIED BY ‘root’;
it is best not to use, it may prompt anonymous users do not allow to change the password and the like.

Description

All relevant directories, links, parameters, etc., please adjust according to the actual situation.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>