In this how-to geek article, the author talked about using
mysqladmin -u root -h host_name password “newpassword”
To set a new password. A person replied that that may leave the password in the shell's history file, and suggested using
mysql -u root mysql
mysql> SET PASSWORD FOR root@localhost=PASSWORD(’newpasswordgoeshere’);
but another person said that it'd leave the password in the .mysql_history file.
Security isn't an issue for me (no-one else should have access to my computer), but is there a better alternative?
As of MySQL 5.5.3, the simplest way is with mysqladmin
:
$ mysqladmin -p -u root password
Enter password: # ← current root password
New password: # ← new root password
Confirm new password: # ← again
You can turn off MySQL history by setting
export MYSQL_HISTFILE=/dev/null
in your shell before starting mysql.
MySQL environment vars reference.
According to wikipedia the windows equivalent of /dev/null
is \Device\Null
or NUL
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With