Solve mysql logon warning and mysql logon warning
I. Preface
We often see a warning when logging on to mysql:
Warning: Using a password on the command line interface can be insecure.
This makes people look uncomfortable, and when writing a script, this warning is output to the screen more uncomfortable.
Ii. Solution
This warning is provided by mysql. It is insecure to directly enter the mysql password on the screen.
1. solution 1)
This solution is relatively simple. When you log on to mysql,-p is not followed by any strings.
This solution indeed avoids warnings. However, if an input error occurs, we can only delete the data again or press ctrl + backspace. We do not know where the error is.
Is it difficult to enter the account and password like this every time? Please refer to the second method.
2. solution 2 (recommended)
Create a hidden file named. my. cnf in the Home Directory (you can specify the directory by yourself.
1. edit the file:
Vim. my. cnf
[Mysql]
Host = 127.0.0.1
User = root
Password = zxfly
2. Perform logon or script operations. Use the following methods:
HOME =/root mysql
Of course, this directory can be any directory as long as it is specified. Any parameters can be added to the file, such as ports and sock files.
You can also specify other mysql commands. Add the corresponding module.
For example, the command mysqldump can be as follows:
[Mysqldump]
Host = 127.0.0.1
User = root
Password = zxfly