Forgot your password MySql Linux environment

Problem Description:
  installation environment CentOS7.5, MySql forget the password, the solution is as follows:

1. Skip MySQL password authentication

1.1 Add skip-grant-tables information [mysqld] down, save and exit

[root@qfx_centos sbin]# vi /etc/my.cnf

Forgot your password MySql Linux environment

1.2 Restart MySql service

[root@qfx_centos ~]# systemctl stop mysqld.service
[root@qfx_centos ~]# systemctl start mysqld.service

Forgot your password MySql Linux environment

2. Modify the MySQL password

2.1 Login MySql (the password is blank, press Enter), refresh the authority information

#登录
[root@qfx_centos ~]# mysql -uroot -p
#更新权限
mysql> flush privileges;

Forgot your password MySql Linux environment

2.2 update password, refresh the authority information

#更新密码
mysql> alter user 'root'@'localhost' identified by 'abc123_';
#更新权限
mysql> flush privileges;

Forgot your password MySql Linux environment

3. Restore MySql permission verification function

3.1 Exit MySql, remove the skip-grant-tables to add information from the /etc/my.cnf

#退出
mysql> quit
#编辑 /etc/my.cnf,去掉 skip-grant-tables 信息
[root@qfx ~]# vi /etc/my.cnf

Forgot your password MySql Linux environment

3.2 Service to restart the MySql again

[root@qfx_centos ~]# systemctl stop mysqld.service
[root@qfx_centos ~]# systemctl start mysqld.service

Forgot your password MySql Linux environment

4. Test connector

Forgot your password MySql Linux environment

Guess you like

Origin blog.51cto.com/1197822/2446408