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

Analysis of MySQL user management operation examples

This article describes the MySQL user management ...

Summary of 3 ways to lazy load vue-router

Not using lazy loading import Vue from 'vue&#...

MySQL Community Server 5.7.19 Installation Guide (Detailed)

MySQL official website zip file download link htt...

Summary of 11 amazing JavaScript code refactoring best practices

Table of contents 1. Extracting functions 2. Merg...

Example of integrating Kafka with Nginx

background nginx-kafka-module is a plug-in for ng...

Alibaba Cloud Server Ubuntu Configuration Tutorial

Since Alibaba Cloud's import of custom Ubuntu...

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security produc...

CSS implements the web component function of sliding the message panel

Hello everyone, I wonder if you have the same con...

Analysis of SQL integrity constraint statements in database

Integrity constraints Integrity constraints are f...

Implementation of react loop data (list)

First, let's simulate the data coming from th...

Docker installation and configuration steps for Redis image

Table of contents Preface environment Install Cre...