mysql コマンドの入力履歴を消す
CentOS 7 に MariaDB を入れると,はじめにrootのパスワードを設定するためにmysqlコマンドを使います.
パスワードの設定の歳には以下のようなコマンドを入力します.
~$ mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
...
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)
MariaDB [(none)]> SELECT user,host,password FROM mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | 127.0.0.1 | |
| root | ::1 | |
+------+-----------+----------+
3 rows in set (0.00 sec)
MariaDB [none]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('hogehogehoge');
Query OK, 0 rows affected (0.00 sec)
このとき,パスワード’hogehogehoge’を平文で入力しなければならず,履歴をたどるとパスワードが分かってしまいます.
目的
mysqlコマンド内での入力履歴を消す
方法
mysqlコマンドでの入力履歴は " $HOME/.mysql_history " に保存されています.
sudoでmysqlを実行した場合は,以下の要領で履歴を消せます.
$ sudo rm -rf /root/.mysql_history
ファイルごと消しても,またmysqlコマンドを使ったら勝手に生成されます(・∀・)
参考:
StackOverflow – How to clear query cache in mysql?
Clear mysql command line history stored in ~/.mysql_history file
ディスカッション
コメント一覧
まだ、コメントがありません