Is there a safe way to configure mysql root password?

In this geek practice article, the author talked about using

mysqladmin -u root -h host_name password "newpassword" 

To set a new password. The man replied that he could leave the password in the shell history file and suggested using

 mysql -u root mysql mysql> SET PASSWORD FOR root@localhost =PASSWORD('newpasswordgoeshere'); 

but another person said that he would leave the password in the .mysql_history file.

Security is not a problem for me (no one should have access to my computer), but is there a more effective alternative?

+4
source share
4 answers

You can disable MySQL history by setting

 export MYSQL_HISTFILE=/dev/null 

in your shell before starting mysql.

MySQL link to the environment .

According to wikipedia, the equivalent of the window /dev/null is \Device\Null or NUL .

+2
source

As in MySQL 5.5.3 , the easiest way is mysqladmin :

 $ mysqladmin -p -u root password Enter password: # ← current root password New password: # ← new root password Confirm new password: # ← again 
+6
source

Why don't you just use one of the options and delete the corresponding history file.

0
source

$ mysqladmin -p -u root password seems to be the best way.

0
source

All Articles