Home > Database > Mysql Tutorial > body text

Solution to mysql login warning problem

小云云
Release: 2017-12-08 10:13:00
Original
2033 people have browsed it

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!