MySQL forgot root password do not restart Mysqld method

Source: Internet
Author: User
Tags reserved

MySQL forgot root password do not restart Mysqld method

1, first there must be a MySQL database account that can have the right to modify, the current MySQL instance account (lower-privileged accounts, such as can modify the Zabbix database) or other instances of the same version of the account. Copy the files associated with the user table below the Data/mysql directory to the Data/zabbix directory.

[email protected] mysql]# CP mysql/user.* test/
[Email protected] mysql]# chown mysql.mysql test/user.*

2. Use another low-privileged account link database to set the user-stored password data in the Zabbix database.


[Email protected] mysql]# mysql-uzabbix-pzabbixpasswd-a
MySQL: [Warning] Using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1180
Server Version:5.7.22-log MySQL Community Server (GPL)

Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> use Zabbix;
Database changed
mysql> Update user Set Authentication_string=password (' zabbixpasswd ') where user= ' root ';
Query OK, 2 rows affected, 1 warning (0.04 sec)
Rows matched:2 Changed:2 warnings:1


3, the user after the change. MyD and user.myi Copy to the MySQL directory, remember to back up the previous files.

MV Mysql/user. MYD Mysql/user. Myd.bak
MV Mysql/user. MYI Mysql/user. Myi.bak
CP Zabbix/user. my* mysql/
Chown Mysql.mysql mysql/user.*

4, Kill-sighup

[[email protected] mysql]# pgrep-n MySQL
31650
[Email protected] mysql]#
[Email protected] mysql]# Kill-sighup 31650

5. Testing
[Email protected] mysql]# mysql-uroot-pzabbixpasswd-a
MySQL: [Warning] Using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1190
Server Version:5.7.22-log MySQL Community Server (GPL)

Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

MySQL forgot root password do not restart Mysqld method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.