質問内容は、mysql コマンドで、ユーザー名、パスワードを入力せずに接続したいと解釈しました。
(パスワードを記載したファイルをサーバー内に設置することになりますので、自己責任で実施してください。)
現在、mysql -u ユーザ名 -p
で、ログインできているのであれば、MySQL の 個人設定ファイルにパスワードを設定ことで、ユーザ名、パスワードの入力を省略することができます。
以下の内容を記載した ~/.my.cnf を作成して、パーミッションを 0600 にする。
[client]
user=ユーザ名
password="my_password"
(参考)
MySQL マニュアル 6.1.2.1 End-User Guidelines for Password Security より
テスト結果
.my.cnf 設定前
$ mysql
ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: NO)
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 598707
Server version: 5.7.17 MySQL Community Server (GPL)
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>
mysql だけではエラー。 ユーザ名、パスワードを入力すると接続できる。
.my.cnf 設定後
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 598708
Server version: 5.7.17 MySQL Community Server (GPL)
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>
mysql だけで接続可能。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/09 14:07
2018/04/09 14:10