MySQL 5.7の問題とmysql_config_editorを使用してrootパスワードをリセットする

MySQL 5.7の問題とmysql_config_editorを使用してrootパスワードをリセットする

私はDebian JessieでMySQL 5.7.17を使用しており、mysqldumpとmysql_config_editorを使用してデータベースをダンプしたいと思います。

mysql_config_editorに対して実行したステップ。彼らは:

mysql_config_editor set --login-path=local --host=localhost --user=root --password
mysql_config_editor print --all

ユーザーはrootになります。

次に、ルートパスワードを変更します。

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables &

新しい端末を開き、次のように入力します。

mysql -u root -p
use mysql;
select user,host from user where user='root';
UPDATE user SET authentication_string=PASSWORD('123456') WHERE user='root';
FLUSH PRIVILEGES;
exit
sudo service mysql stop
sudo service mysql start

次に、次のコマンドを実行します。

mysqldump --login-path=local parana > parana.sql

次のメッセージを受け取りました。

mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

cpn mysqldumpと--login-pathをバックアップできる問題をどのように解決しますか、それともバックアップすることができますか?非常にありがとう

ベストアンサー1

私も同じ奇妙な行動に苦しんでいます。

スクリプトでコマンドを使用する場合:

/usr/bin/mysqldump -h localhost -u root -pmy#rootpassword mysql --tables db >> mysql-db_2017-03-17_09-50-35.sql

警告が表示されます。

Warning: Using a password on the command line interface can be insecure.

だから私はバックアップスクリプトを次のように変更しました。

/usr/bin/mysqldump --login-path=backups mysql --tables db >> mysql-mysql-db_2017-03-17_08-24-07.sql

しかし、これはエラーを引き起こします。

mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

公式のMySQLドキュメントでは、「mysql」コマンドを使用して設定を試すことをお勧めします。
https://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html

ローカルサーバーに接続するには、次のコマンドを使用します。shell
> mysql --login-path=client

実際、私はこのように同じエラーが発生することを発見しました。

$ mysql --login-path=backups
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

私はMySQLドキュメントの一番下にある次のコメントを偶然発見するまではそれを理解できませんでした。

パスワード文字列に「#」文字が含まれていると、文字列を読み取るときにハッシュ文字がコメントの先頭として扱われるため、認証は失敗します。

これにより、MySQLのバグページが表示されます。
https://bugs.mysql.com/bug.php?id=74691

そこで私に役立つ提案された解決策を見つけました。

回避策は、「pass#pass」という引用符の中にパスワードを入力することです。
提案された修正:
すべての文字列を引用符で囲みます。

そのため、「mysql_config_editor」にパスワードを再入力しました。

$ mysql_config_editor set --login-path=scripts --host=localhost --user=root --password
Enter password: -> typeing: "my#rootpassword" <- including the character >"<
WARNING : 'scripts' path already exists and will be overwritten. 
 Continue? (Press y|Y for Yes, any other key for No) : y

最後に正常にログインしました:

$ mysql --login-path=scripts
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 139
Server version: 5.6.35-log Distributed by The IUS Community Project
Copyright (c) 2000, 2016, 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> exit
Bye

おすすめ記事