Is it possible to remove the prompt history on MariaDB? - mariadb
The main problem is that I wrote a security sensitive statement on MariaDB (among many other statements), so I would like to remove the prompt history (like the command history -c on Linux):
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)
So, when I click the up&down buttons on my keyboard I see all the prompt history.
When I try to remove the prompt history on MariaDB, it does not work:
MariaDB [(none)]> clear
MariaDB [(none)]> \c
MariaDB [(none)]> quit
Bye
So, I have checked on the internet this script (that does not work either):
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
REFERENCE > https://www.thegeekstuff.com/2010/01/disable-mysql-history-clear-mysql_history-and-mysql_histfile/
After that, I have also checked on the internet another script (that does not work either, again):
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
REFERENCE > https://www.cyberciti.biz/faq/howto-clear-mysql-command-history/
One the one hand, there are too many files on my OS related to "mysql" but none related to mysql history, so I have checked one by one all the files related to mysql configuration and I did not find the one I should remove:
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
One the other hand, the same happens with the mariadb files:
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
Could you please give me a hint? You can check that I have tried it. Thanks in advance.
PS_1: if there is any other entry about this topic on Stack* (I have checked it and I did not see one) or if my entry breaks any rule on Stack* (I have checked the rules and I think I do not break any), please send me a PM and I will delete this entry. I am trying to learn without losing reputation points for asking a question.
PS_2: I have restarted mysql and right now the status is active (running):
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.
REFERENCE > https://superuser.com/questions/282115/how-to-restart-mysql
PS_3: I have tried the command stat ~/.mysql_history; rm ~/.mysql_history; stat ~/.mysql_history and the output that I have is that the file or the directory /home/jordiba90/.mysql_history does not exist
PS_4: I have tried the command strace mysql and I can not share here the output because there is a message body limit to 30.000 characters (and if I do that, I should have entered 44.321, aprox)
PS_5: Having checked the specific output openat(AT_FDCWD..., there is none related to mysql_history. It does not appear that specific sentence
PS_6: I have used 'sudo' to try the command 'strace mysql'and I have got the following output related to mysql history:
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: I have removed the last directory related to mysql history named /root/.mysql_history but I still see the history on the mariadb prompt
Editing the history file (for example with vim, and deleting the problematic lines) worked in my case:
vim ~/.mysql_history
(mysql Ver 15.1 Distrib 10.4.14-MariaDB)
Depending on how you are set up, you'll probably find it is located at root. I had the same on a new secured install of MariaDB on Ubuntu 22.04. Mine was located at /root/.mysql_history
I found it the usual way by using the excellent locate command (remember to use the updatedb command to update the database of any new files that have been added) and searching for mysql_history:
locate -i mysql_history
Do this search at the bash (or whatever you are using) command prompt as you are searching for a file in the file system, not in the MariaDB or MySQL shell itself.
On this search, there is no actual need for the -i option as mysql_history is lowercase, but you never know!
Searching for history will also work but you'll get a few more hits.
Once you have found the file, you can use the editor of your choice to remove any sensitive command lines that may have found their way in there.
Related
lxc-start: controller: lxccontainer.c: wait_on_daemonized_start: 842 Received container state "STOPPING" instead of "RUNNING"
when i run the config file config file sudo lxc-start -n controller -d it gives me this error lxc-start: controller: lxccontainer.c: wait_on_daemonized_start: 842 Received container state "STOPPING" instead of "RUNNING" lxc-start: controller: tools/lxc_start.c: main: 330 The container failed to start lxc-start: controller: tools/lxc_start.c: main: 333 To get more details, run the container in foreground mode lxc-start: controller: tools/lxc_start.c: main: 336 Additional information can be obtained by setting the --logfile and --logpriority options Additional information lxc-start --version 3.0.3 uname -a Linux shahrukh-VirtualBox 3.12.74-031274-generic #201705101001 SMP Wed May 10 14:04:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
It turns out that there were old config files for apparmor in my system that didn't get updated along with apparmor. Simply doing this fixed it: sudo -sH # become root apt purge apparmor* # uninstall apparmor and its configs apt install apparmor* # reinstall it apparmor_status # check if apparmor is running # If the above status shows 0 for every profile or other error # check first if apparmor is activated in the kernel through grub cat /sys/module/apparmor/parameters/enabled # if the above doesn't return "Y", then activate it first mkdir -p /etc/default/grub.d echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT apparmor=1 security=apparmor"' \ | tee /etc/default/grub.d/apparmor.cfg update-grub reboot
Problems installing artifactory service on Ubuntu 16.04 Xenial (HVM) Amazon AWS image
I'm getting this, which doesn't help me a lot. Tomcat logs are not yet created, and the war files not yet expanded, so I guess tomcat cannot even start. How can I figure out the problem? systemctl status artifactory.service ● artifactory.service - Setup Systemd script for Artifactory in Tomcat Servlet Engine Loaded: loaded (/lib/systemd/system/artifactory.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Mon 2018-02-05 22:25:30 CET; 1s ago Process: 13760 ExecStart=/0/artifactory/bin/artifactoryManage.sh start (code=exited, status=1/FAILURE) I followed these installation instructions, downloaded and extracted JFrog Artifactory OSS 5.8.3, then unzip /0/artifactory.zip -d /0 mv /0/artifactory-oss-5.8.3 /0/artifactory chmod +x /0/artifactory/bin/* ARTIFACTORY_HOME=/0/artifactory bash -c '/0/artifactory/bin/installService.sh' Then edited /etc/opt/jfrog/artifactory/default: #!/bin/sh #Default values export ARTIFACTORY_HOME=/0/artifactory export ARTIFACTORY_USER=artifactory export JAVA_HOME=/a/java/jdk1.8_lin64 export TOMCAT_HOME=/0/artifactory/tomcat export ARTIFACTORY_PID=$ARTIFACTORY_HOME/run/artifactory.pid export JAVA_OPTIONS="-server -Xms512m -Xmx756m -Xss256k -XX:+UseG1GC -XX:OnOutOfMemoryError=\"kill -9 %p\"" export JAVA_OPTIONS="$JAVA_OPTIONS -Djruby.compile.invokedynamic=false -Dfile.encoding=UTF8 -Dartdist=zip -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Djava.security.egd=file:/dev/./urandom" # Timeout waiting for artifactory to start # START_TMO=60 Finally reinstalled service (do I have to uninstall somehow first?) ARTIFACTORY_HOME=/0/artifactory bash -c '/0/artifactory/bin/installService.sh' systemctl start artifactory.service || true systemctl status artifactory.service
Turns out it was a permissions problem. Eventually I unzipped to /opt/artifactory (instead of /0/artifactory), and things started to work. I found the problem by trying to manually start artifactory. I looked inside /opt/artifactory/misc/service/artifactory.service and found: ExecStart=/opt/jfrog/artifactory/bin/artifactoryManage.sh start Inside artifactoryManage.sh I looked at the start method and found: su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/startup.sh" I manually resolved the variables by changing this to: su -s "/bin/sh" artifactory -c "export JAVA_HOME=/a/java/jdk1.8_lin64; /opt/artifactory/tomcat/bin/startup.sh" And then received the permission error. I vaguely remembered reading something about permissions in the installation instructions:
Accidentally used -S when creating my tmux session instead of -s, where is my session?
I created a new session of tmux, intending to use the -s flag to name it, but confused the command with -S which specifies a socket. I know the session is alive, because the processes I started in it are still running. But when I try to list running sessions it does not appear. Where is my session and how do I recover it?
In tmux option -S means socket path (from man tmux): -S socket-path Specify a full alternative path to the server socket. If -S is specified, the default socket directory is not used and any -L flag is ignored. So you have to find out the parent directory where tmux was run with -S option and pass this option to tmux to point it to the alternative socket path. You could for example find PID of the tmux process: $ ps aux | grep '[t]mux' ja 15121 0.0 0.0 20252 2236 pts/6 S+ 00:44 0:00 tmux -S new And then check this process cwd in /proc like this: $ ls -l /proc/15121/cwd lrwxrwxrwx 1 ja users 0 Aug 19 00:52 /proc/15121/cwd -> /home/ja And then to refer to this tmux session: $ tmux -S /home/ja/new ls 0: 1 windows (created Sat Aug 19 00:44:46 2017) [212x65] (attached)
Mounting VMDK disk image
I have a single vmware disk image file with vmdk extension I am trying to mount this and explore all of the partitions (including hidden ones). I've tried to follow several guides, such as : http://forums.opensuse.org/showthread.php/469942-mounting-virtual-box-machine-images-host I'm able to mount the image using vdfuse vdfuse -w -f windows.vmdk /mnt/ After this I can see one partition and an entire disk exposed # ll /mnt/ total 41942016 -r-------- 1 te users 21474836480 Feb 28 14:16 EntireDisk -r-------- 1 te users 1569718272 Feb 28 14:16 Partition1 Continuing with the guide I try to mount either EntireDisk or Partition1 using mount -o loop,ro /mnt/Partition1 mnt2/ But that gives me the error 'mount: you must specify a filesystem type' In trying to find the correct type I tried dd if=/mnt/EntireDisk | file - which outputs a ton of information but of note is: /dev/stdin: x86 boot sector; partition 1: ....... FATs .... So i tired to mount as a vfat but that gave me mount: wrong fs type, bad option, bad superblock ...etc What am I doing wrong?
For newer Linux systems, you can use guestmount to mount the third partition within a VMDK image: guestmount -a xyz.vmdk -m /dev/sda3 --ro /mnt/vmdk Alternatively, to autodetect and mount an image (less reliable), you can try: guestmount -a xyz.vmdk -i --ro /mnt/vmdk Do note that the flag --ro simply mounts the image as read-only; to mount the image as read-write, just replace it with the flag --rw. Installation guestmount is contained in following packages per distro: Ubuntu: libguestfs-tools OpenSuse: guestfs-tools CentOS / Fedora: libguestfs-tools-c Troubleshooting error: could not create appliance through libvirt $ guestmount -a file.vmdk -i --ro /mnt/guest libguestfs: error: could not create appliance through libvirt. Try running qemu directly without libvirt using this environment variable: export LIBGUESTFS_BACKEND=direct Original error from libvirt: Cannot access backing file '/path/to/file.vmdk' of storage file '/tmp/libguestfssF6WKX/overlay1.qcow2' (as uid:107, gid:107): Permission denied [code=38 int1=13] Solution: use LIBGUESTFS_BACKEND=direct, as suggested: LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest fusermount: user has no write access to mountpoint LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest/ fusermount: user has no write access to mountpoint /mnt/guest libguestfs: error: fuse_mount failed: /mnt/guest/, see error messages above Solution: use sudo, or change file permissions on the mountpoint
You can also use qemu: For .vdi disks sudo modprobe nbd sudo qemu-nbd -c /dev/nbd1 ./linux_box/VM/image.vdi if they are not installed, you can install them (issuing this command in Ubuntu) sudo apt install qemu-utils and then mount it with: mount /dev/nbd1p1 /mnt For .vmdk disks sudo modprobe nbd sudo qemu-nbd -r -c /dev/nbd1 ./linux_box/VM/image.vmdk notice that I use the option -r, that's because VMDK version 3 must be read only to be able to be mounted by qemu and then I mount it with mount /dev/nbd1p1 /mnt I use nbd1, because nbd0 sometimes gives: 'mount: special device /dev/nbd0p1 does not exist' For .ova disks tar -tf image.ova tar -xvf image.ova The above will extract the .vmdk disk and then mount it.
Install affuse, then mount using it. affuse /path/file.vmdk /mnt/vmdk The raw disk image is now found under /mnt/vmdk. Check its sector size: fdisk -l /mnt/vmdk/file.vmdk.raw # example Disk file.vmdk.raw: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x000da525 Device Boot Start End Sectors Size Id Type /mnt/vmdk/file.vmdk.raw1 * 2048 41943039 41940992 20G 83 Linux Multiply sector size and start sector. In the example it would be 2048*512: echo '2048*512' | bc 1048576 Mount the raw file using that offset: mount -o ro,loop,offset=1048576 /mnt/vmdk/file.raw /mnt/vmdisk The disk should now be mounted and readable on /mnt/vmdisk.
Here is an answer from commandlinefu.com that worked for me: kpartx -av <image-flat.vmdk>; mount -o /dev/mapper/loop0p1 /mnt/vmdk You can also activate LVM volumes in the image by running vgchange -a y and then you can mount the LV inside the image. To unmount the image, umount the partition/LV, deactivate the VG for the image vgchange -a n <volume_group> then run kpartx -dv <image-flad.vmdk> to remove the partition mappings.
You can take a look in this article for a download link for VMware Virtual Disk Development Kit (VDDK). Once downloaded and installed: vmware-mount -p path_to_vmdk will show the partitions inside the VMDK file. For example: Nr Start Size Type Id Sytem -- ---------- ---------- ---- -- ------------------------ 1 2048 461371392 BIOS 83 Linux Then just do: sudo vmware-mount path_to_vmdk 1 /mnt/mount_point I tried guestmount, but it is very, very slow. Underneath it creates a virtual machine, uses KVM and so on. Crazy stuff, slow as hell.
Have you got the software package for ntfs? Try apt-get install ntfs-3g on debian based systems.
netstat command doesnt work anymore on the new dedicated server
I was using the following command on my previous dedicated server with the same version of the FreeBSD installation: # uname -a FreeBSD 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013 root#bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 The command is following: netstat -ntu -f inet Output: netstat: illegal option -- t Why doesn't it work anymore? I dont have an access to my previous dedicated server so I can't use the man to check the differences...
You can check man on the freebsd website in short review i see that -t was removed in 9.X branch for some reasons