Solution to mysql login warning problem

Solution to mysql login warning problem

1. Introduction

When we log in to MySQL, we often see a warning:

Warning: Using a password on the command line interface can be insecure.

This is annoying to look at, and even more annoying when this warning is printed to the screen while writing a script.

2. 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 take a look, it’s useless)

The solution is relatively simple. When you log in to mysql, do not follow any string after -p.

This solution does avoid the warning, but if we make a mistake in input, we can only re-enter the data or press ctrl+backspace to delete it, and we still don’t know where the mistake is.

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.cnf in your home directory (you can specify the directory yourself).

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. Arbitrary parameters can be added to the file, such as port, sock file, etc.

Other mysql commands can also be specified in the file. Just add the corresponding modules.

For example: the command mysqldump can be as follows

[mysqldump]
host=127.0.0.1
user=root
password=zxfly

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Explain MySQL installation and login method under Linux
  • Solve phpmyadmin #2002 Unable to log in to MySQL server
  • phpmyadmin error: #2003 Unable to log in to MySQL server solution
  • About MYSQL remote login authorization method command
  • Solution to the problem of being unable to log in locally even though the MySQL password is correct
  • MySQL login error prompt: Solution to ERROR 1045 (28000)
  • PHP+MySQL implements login verification to see if the login name and password are correct
  • How to solve the ERROR 1045 problem when logging into mysql
  • A quick solution to the MySql crash when logging in
  • PHP+MySQL to implement a simple login, registration and password modification web page

<<:  WeChat applet implements video player sending bullet screen

>>:  Explanation of Mac connecting to remote servers through SSH in different terminals

Recommend

MySQL obtains the current date and time function example detailed explanation

Get the current date + time (date + time) functio...

Implementation of react routing guard (routing interception)

React is different from Vue. It implements route ...

Summary of DTD usage in HTML

DTD is a set of grammatical rules for markup. It i...

Deploy Confluence with Docker

1. Environmental requirements 1. Docker 17 and ab...

Detailed tutorial on using the tomcat8-maven-plugin plugin in Maven

I searched a lot of articles online but didn'...

Learn one minute a day to use Git server to view debug branches and fix them

Debug branch During the normal development of a p...

Detailed explanation of MySQL from getting started to giving up - installation

What you will learn 1. Software installation and ...

Three.js realizes Facebook Metaverse 3D dynamic logo effect

Table of contents background What is the Metavers...

MySQL 5.7.23 decompression version installation tutorial with pictures and text

It is too troublesome to find the installation tu...

Detailed explanation of HTML basics (Part 1)

1. Understand the WEB Web pages are mainly compos...

How to quickly query 10 million records in Mysql

Table of contents Normal paging query How to opti...

Using group by in MySQL always results in error 1055 (recommended)

Because using group by in MySQL always results in...

MySQL scheduled backup solution (using Linux crontab)

Preface Although some love in this world has a pr...

Docker installation rocketMQ tutorial (most detailed)

RocketMQ is a distributed, queue-based messaging ...

Several ways to improve the readability of web pages

1. Use contrasting colours. The contrast here ref...