簡體   English   中英

MariaDB上的提示歷史是否可以去掉?

[英]Is it possible to remove the prompt history on MariaDB?

主要問題是我在MariaDB上寫了一條安全敏感語句(以及許多其他語句),所以我想刪除提示歷史記錄(如 Linux 上的命令history -c ):

jordiba90@lts:~$ sudo mariadb -u root -p
[sudo] contraseña para jordiba90: 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.25-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
    
MariaDB [mysql]> UPDATE user SET password=PASSWORD("PASSWORD") WHERE user="root";
Query OK, 0 rows affected (0.001 sec)
Rows matched: 1 Changed: 0 Warnings: 0

MariaDB [mysql]> FLUSH privileges;
Query OK, 0 rows affected (0.001 sec)

因此,當我單擊鍵盤上的向上和向下按鈕時,我會看到所有提示歷史記錄

當我嘗試刪除 MariaDB 上的提示歷史時,它不起作用:

MariaDB [(none)]> clear

MariaDB [(none)]> \c

MariaDB [(none)]> quit
Bye

所以,我在 inte.net 上檢查了這個腳本(也不起作用):

jordiba90@lts:~$ rm ~/.mysql_history

jordiba90@lts:~$ export MYSQL_HISTFILE=/dev/null

jordiba90@lts:~$ set | grep MYSQ
MYSQL_HISTFILE=/dev/null
_=MYSQL_HISTFILE=/dev/null

參考 > https://www.thegeekstuff.com/2010/01/disable-mysql-history-clear-mysql_history-and-mysql_histfile/

之后,我還在 inte.net 上檢查了另一個腳本(同樣也不起作用):

jordiba90@lts:~$ ~/.mysql_history
bash: /home/jordiba90/.mysql_history: No existe el archivo o el directorio

jordiba90@lts:~$ rm $HOME/.mysql_history
rm: no se puede borrar '/home/jordiba90/.mysql_history': No existe el archivo o el directorio

jordiba90@lts:~$ ln -s /dev/null $HOME/.mysql_history

參考 > https://www.cyberciti.biz/faq/howto-clear-mysql-command-history/

一方面,我的操作系統上有太多與“mysql”相關的文件,但沒有一個與 mysql 歷史相關,所以我一一檢查了所有與 mysql 配置相關的文件,但沒有找到我應該刪除的文件:

jordiba90@lts:~$ locate mysql | wc
    421     421   25918

jordiba90@lts:~$ locate mysql | grep history

jordiba90@lts:~$ locate mysql | grep conf
/etc/mysql/conf.d
/etc/mysql/conf.d/mysql.cnf
/etc/mysql/conf.d/mysqldump.cnf
/etc/mysql/mariadb.conf.d
/etc/mysql/mariadb.conf.d/50-client.cnf
/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
/etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf
/etc/mysql/mariadb.conf.d/50-server.cnf
/usr/share/mysql-common/configure-symlinks
/usr/share/mysql/systemd/use_galera_new_cluster.conf
/var/lib/dpkg/info/mysql-common.conffiles

另一方面,mariadb 文件也會發生同樣的情況:

jordiba90@lts:~$ locate mariadb | wc
    101     101    5042

jordiba90@lts:~$ locate mariadb | grep history

jordiba90@lts:~$ locate mariadb | grep conf
/etc/insserv.conf.d/mariadb
/etc/mysql/mariadb.conf.d
/etc/mysql/mariadb.conf.d/50-client.cnf
/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
/etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf
/etc/mysql/mariadb.conf.d/50-server.cnf
/usr/lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
/var/lib/dpkg/info/mariadb-client-10.3.conffiles
/var/lib/dpkg/info/mariadb-common.conffiles
/var/lib/dpkg/info/mariadb-server-10.3.conffiles
/var/lib/dpkg/info/mariadb-server-10.3.config

你能給我一個提示嗎? 你可以檢查我是否嘗試過。 提前致謝。

PS_1:如果 Stack* 上還有關於此主題的任何其他條目(我已經檢查過但沒有看到)或者我的條目是否違反了 Stack* 上的任何規則(我已經檢查過規則但我認為我沒有違反任何規則), 請給我發一個 PM,我會刪除這個條目。 我正在努力學習而不因提問而失去聲譽點數。

PS_2:我已經重啟了 mysql,現在狀態是活動的(運行中):

jordiba90@lts:~$ sudo /etc/init.d/mysql restart
Restarting mysql (via systemctl): mysql.service.

jordiba90@lts:~$ sudo /etc/init.d/mysql status
● mariadb.service - MariaDB 10.3.25 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-11-14 13:24:47 CET; 8h ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 826 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 861 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 876 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 1026 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1028 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 957 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 31 (limit: 9423)
     Memory: 93.1M
     CGroup: /system.slice/mariadb.service
             └─957 /usr/sbin/mysqld

nov 14 13:24:46 lts systemd[1]: Starting MariaDB 10.3.25 database server...
nov 14 13:24:47 lts mysqld[957]: 2020-11-14 13:24:47 0 [Note] /usr/sbin/mysqld (mysqld 10.3.25-MariaDB-0ubuntu0.20.04.1) starting as…ess 957 ...
nov 14 13:24:47 lts mysqld[957]: 2020-11-14 13:24:47 0 [Warning] Could not increase number of max_open_files to more than 16384 (request: 32186)
nov 14 13:24:47 lts systemd[1]: Started MariaDB 10.3.25 database server.
nov 14 13:24:47 lts /etc/mysql/debian-start[1030]: Upgrading MySQL tables if necessary.
nov 14 13:24:47 lts /etc/mysql/debian-start[1033]: Looking for 'mysql' as: /usr/bin/mysql
nov 14 13:24:47 lts /etc/mysql/debian-start[1033]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
nov 14 13:24:47 lts /etc/mysql/debian-start[1033]: This installation of MySQL is already upgraded to 10.3.25-MariaDB, use --force if y…l_upgrade
Hint: Some lines were ellipsized, use -l to show in full.

參考 > https://superuser.com/questions/282115/how-to-restart-mysql

PS_3:我試過命令stat ~/.mysql_history; rm ~/.mysql_history; stat ~/.mysql_history stat ~/.mysql_history; rm ~/.mysql_history; stat ~/.mysql_history stat ~/.mysql_history; rm ~/.mysql_history; stat ~/.mysql_history和我的 output 是文件或目錄/home/jordiba90/.mysql_history不存在

PS_4:我試過命令strace mysql我不能在這里分享 output 因為消息正文限制為 30.000 個字符(如果我這樣做,我應該輸入 44.321,aprox)

PS_5:查了具體的 output openat(AT_FDCWD... , 沒有和mysql_history相關的。具體的那句話沒有出現

PS_6:我使用“sudo”來嘗試命令“strace mysql”,我得到了以下與 mysql 歷史相關的 output:

openat(AT_FDCWD, "/root/.mysql_history", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=4585, ...}) = 0
read(4, "misql -u root -p\nDatascience2005"..., 4585) = 4585
close(4)                                = 0
write(1, "\33(B\33[m\33(B\33[0;1mType 'help;' or '"..., 94Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
) = 94
write(1, "\n", 1
) 

PS_7:我刪除了與 mysql 歷史相關的最后一個名為/root/.mysql_history的目錄,但我仍然在 mariadb 提示符下看到歷史

編輯歷史文件(例如使用 vim,並刪除有問題的行)在我的案例中有效:

vim ~/.mysql_history

(mysql Ver 15.1 Distrib 10.4.14-MariaDB)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM