大网数据广告活动
服务器运维问答

MySQL cli does not remember history of some commands

· 52CE 我爱测

I use linux OS with mysql database. mysql CLI doesn't log some commands in ~/.mysql_history . For example can not log create user . How can force cli to store all commands in mysql_history ? How can fix this problem ?

问题原文

原帖链接 · mah454 · CC BY-SA 4.0

I use linux OS with mysql database.

mysql CLI doesn't log some commands in ~/.mysql_history .
For example can not log create user.

How can force cli to store all commands in mysql_history ?
How can fix this problem ?

社区高分解答

原帖链接 · HBruijn · CC BY-SA 4.0

That behaviour is by design, which as far as I know you can not override.
By default all interactive statements are logged, including the CREATE USER statement, except when they contain password information.

Although you can add extra conditions that will prevent logging certain additional statements (set either the --histignore option or the MYSQL_HISTIGNORE environment variable) or completely stop logging with for instance the --batch switch, logging passwords is as far as I know not possible.

https://dev.mysql.com/doc/refman/5.7/en/mysql-logging.html

mysql ignores for logging purposes statements that match any pattern in the “ignore” list. By default, the pattern list is "*IDENTIFIED*:*PASSWORD*", to ignore statements that refer to passwords.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-11-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。