MySQLのrootパスワードを忘れましたか?恐れることなく、パスワードをリセットする方法を教えてください!

1.構成ファイルmy.cnfを変更し、構成ファイル[mysqld]の下にskip-grant-tablesを追加し、MySQLサービスを再起動してパスワードなしでログインします。

--skip-grant-tablesオプションは、MySQLサービスの開始時に承認テーブル認証をスキップすることを意味します。起動後、MySQLに接続するルートはパスワードを必要としません(危険です)。

[mysqld]

skip-grant-tables

2.空白のパスワードを持つrootユーザーでMySQLに接続し、rootパスワードを変更します。

[root@iZ235wguph2Z www]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 295

Server version: 5.0.56-log Source distribution

Copyright (c) 2000, 2017, 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> update user set password=password('123456') where User='root';

ERROR 1046 (3D000): No database selected

mysql> use mysql;

Database changed

mysql> update user set password=password('123456') where User='root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

3. my.cnfに移動し、skip-grant-tablesオプションを削除してから、MySQLサービスを再起動します。

この時点で、MySQLデータベースのrootユーザーのパスワードが変更されています。

さらに、プログラミング能力を向上させたい場合は、C言語とC ++プログラミングを学んでください。カーブで追い越し、一歩速く!ここでお手伝いできるかもしれません〜

共有(ソースコード、実際のプロジェクトビデオ、プロジェクトノート、基本的な入門チュートリアル)

キャリアを変えてプログラミングを学び、自分で考えるよりも早く学び成長するために、より多くの情報を使用するパートナーを歓迎します!

プログラミング学習:

プログラミング学習:

おすすめ

転載: blog.csdn.net/weixin_45713725/article/details/114410164