When I login to MySQL as root I usually set MROOTPASS environment variable
export MROOTPASS=my-secret-password
and then do
mysql -u root -p$MROOTPASS
this eliminates the need to reenter the password each time I connect to MySQL as root, but obviously it is insecure because the password is saved to the bash history file. Is it possible to prevent the password from being saved?
MROOTPASS
if you are using it in the same shell session where you define it./root/.my.cnf
where for each block, e.g.[mysqladmin]
,[mysql]
,[mysqldump]
, etc... you can provide thepassword = xxxx
anduser = xxxx
to allow access without needing to provide a user or password on the command line. See MySQL Option Files -- which is the same for MariaDB.