Show MySQL client history

Like most administrators I like to execute MySQL queries direct from the MySQL commandline.

But if you want to review whatever you entered in the client it is sometimes difficult to find.

However: All commands entered are also saved in your homedir from the Linux user you are logged in from.

cat ~/.mysql_history

The result is a complete list of commands you have used:

\q
show slave status\G
show master status;
show databases;
use testdb
INSERT INTO users(name) VALUES ('bla');
\q

Set or reset password for MySQL user

If you want to reset or set a password for an already created user, you have 3 options:

  • Set the password with a current password encryption/hash:
SET PASSWORD FOR 'mysqluser'@'localhost' = PASSWORD('newpassword');
  • Set the password with an old password encryption/hash:
SET PASSWORD FOR 'mysqluser'@'localhost' = OLD_PASSWORD('newpassword');
  • Set the password direct with a predefined hash:
SET PASSWORD FOR 'mysqluser'@'localhost' = '*67BECF85308ACF0261750DA1075681EE5C412F05';

After setting the new password:

flush privileges;