We often see a warning when logging in to mysql: Warning: Using a password on the command line interface can be insecure. This makes people look very uncomfortable, and when writing scripts, this warning is output to It feels even more uncomfortable on screen. In this article, we will share with you the solution to the MySQL login warning problem.
Solution
This warning comes with mysql. It wants to tell you that it is unsafe to enter the mysql password directly on the screen and display it.
1. Solution 1 (just look at it, it’s useless)
This solution is relatively simple. When you log in to mysql- p is not followed by any string.
This solution does circumvent the warning, but if we make a mistake in input, we can only re-data or ctrl+backspace to delete, and we still don’t know what went wrong.
Do you feel that it is troublesome to enter your account and password every time? Then please see the second method.
2. Solution 2 (recommended)
Create a hidden file named .my in the home directory (you can specify the directory yourself). cnf.
1. Edit the file:
vim .my.cnf [mysql] host=127.0.0.1 user=root password=zxfly
2. When executing login or script. Use the following method:
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, sock files, etc.
Other mysql commands can also be specified in the file. Just add the corresponding module.
For example: the command mysqldump can be as follows
[mysqldump] host=127.0.0.1 user=root password=zxfly
You can try it using the above method.
Related recommendations:
How to ignore warning (warning) errors in python
php pop-up error warning function
Zend Studio removes the syntax warning setting method of the editor_PHP tutorial
The above is the detailed content of Solution to mysql login warning problem. For more information, please follow other related articles on the PHP Chinese website!