Solve mysql logon warning and mysql logon warning

Source: Internet
Author: User
Tags mysql commands

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.