


How to quickly log in to MySQL database without password under Shell_Mysql
This article mainly introduces you to the method of realizing password-free quick login MySQL database under Shell. The step-by-step introduction in the article is very detailed through sample code, which has certain reference and learning value for everyone. Friends who need it, please follow the editor to take a look.
Background
When we want to log in to the MySQL database through mysql-client under Shell, we always need to be very troublesome Enter your password again and again.
Moreover, if your root password is highly random (LastPass is good), then the cost of logging into the MySQL database once will be very high.
Usually we log in like this when we log in to the database, as follows
root@imlonghao:~# mysql -uroot -p Enter password:
So, is there a way to log in to the database that is both safe and simple and convenient? Going?
Method
Of course the answer is yes, and MySQL has already helped us think about this problem!
Reference link: End-User Guidelines for Password Security
Use .my.cnf to quickly log in
In~/ Create a new .my.cnf file in the directory. Of course, if you already have this file, just modify it directly!
I personally like to use the vim method, so we can do this
vim ~/.my.cnf
Then write the following information in the file
[client] password=your_pass user=your_user
Note:Modify your_pass and your_user to the password and username of the user you want to log in to
The following is an example:
[client] password=mysqlrootpassword123321 user=root
If you already have the .my.cnf file, Just write the information in the [client] field!
Note: Since your password is written in plain text in the .my.cnf file, please pay attention to setting the file permissions of this file
root@imlonghao:~# chmod 400 ~/.my.cnf
After saving, we can directly use the mysql command to log in to the MySQL database!
Note: If you need to specify a settings file instead of using the default ~/.my.cnf, you need to use --defaults- file=file_name
parameters. Example:
root@imlonghao:~# mysql --defaults-file=/home/imlonghao/mysql-opts
Use environmentVariables MYSQL_PWD Quick login
MySQL will first use the parameters in the environment variable as the run After the parameter
root@imlonghao:~# export MYSQL_PWD=your_pass
is set, you do not need to enter the password again when logging in to mysql again.
However, it should be noted that if you exit the current Shell, this environment variable will disappear.
What needs more attention is that the commands you enter in the Shell will be automatically saved, and history can see the commands you entered.
Summarize
The above is the detailed content of How to quickly log in to MySQL database without password under Shell_Mysql. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Some players are experiencing a strange issue on PS4 or PS5 at launch. For example, this can cause distress when their PlayStation Network login fails, but their internet connection is fine. You may encounter errors when entering your login information and may not be able to join PSParty chat. If you encounter a similar problem, this guide may help you solve it. Next to PlayStationNetworkSign-in, you will see the error message ‘AnErrorHaveAreAre’ and it will say ‘Failure’. Other parameters like getting IP address, internet connection and connection speed were successful. So, what could be the problem here? I will give you a job

The AADSTS7000112 error may prevent you from logging into the app using your Microsoft account, causing you inconvenience. This article will provide you with solutions to help you resolve this issue and restore a normal login experience. Login: Sorry, you are having trouble logging in. AADSTS7000112: Application disabled. Fortunately, you can fix the error by following some simple suggestions. What is error code AADSTS7000112? Error code AADSTS7000112 indicates a problem with the connection to Microsoft's Azure Active Directory. Typically, this may be due to the Microsoft application trying to log in being blocked.

When processing files under Linux systems, it is sometimes necessary to delete lines at the end of the file. This operation is very common in practical applications and can be achieved through some simple commands. This article will introduce the steps to quickly delete the line at the end of the file in Linux system, and provide specific code examples. Step 1: Check the last line of the file. Before performing the deletion operation, you first need to confirm which line is the last line of the file. You can use the tail command to view the last line of the file. The specific command is as follows: tail-n1filena

How to log in to the email address of Enterprise WeChat? You can log in to the email address in the Enterprise WeChat APP, but most users don’t know how to log in to the email address. Next is the graphic tutorial on how to log in to the email address of Enterprise WeChat brought by the editor for interested users. Come and take a look! Enterprise WeChat usage tutorial How to log in to the Enterprise WeChat email 1. First open the Enterprise WeChat APP, go to the [Workbench] at the bottom of the main page and click to come to the special area; 2. Then in the workbench area, select the [Enterprise Mailbox] service; 3. Then jump to the corporate email function page, click [Bind] or [Change Email] at the bottom; 4. Finally, enter [QQ Account] and [Password] on the page shown below to log in to the email.
![GeForce Experience login freezes [Fix]](https://img.php.cn/upload/article/000/887/227/171084420790568.png?x-oss-process=image/resize,m_fill,h_207,w_330)
This article will guide you to solve the GeForceExperience login crash issue on Windows 11/10. Typically, this can be caused by unstable network connections, corrupted DNS cache, outdated or corrupted graphics card drivers, etc. Fix GeForceExperience Login Black Screen Before starting, make sure to restart your internet connection and computer. Sometimes, the problem may just be due to a temporary issue. If you are still experiencing NVIDIA GeForce Experience login black screen issue, please consider taking the following suggestions: Check your internet connection Switch to another internet connection Disable your

Compare SpringBoot and SpringMVC and understand their differences. With the continuous development of Java development, the Spring framework has become the first choice for many developers and enterprises. In the Spring ecosystem, SpringBoot and SpringMVC are two very important components. Although they are both based on the Spring framework, there are some differences in functions and usage. This article will focus on comparing SpringBoot and Spring

Wegame is a software used with Tencent games. You can use it to start games and gain acceleration. Recently, many users have experienced prompts that login operations are too frequent when using it. Faced with this prompt, many users do not know How can we solve it successfully? In this software tutorial, we will share the solution with you. Let’s learn about it together. What should I do if Wegame login operations are too frequent? Method 1: 1. First, make sure our network connection is normal. (You can try opening the browser to see if you can access the Internet) 2. If it is a network failure, then try restarting the router, reconnecting the network cable, and restarting the computer to solve the problem. Method 2: 1. If there is no problem with the network, then select &

What is the difference in the "My Computer" path in Win11? Quick way to find it! As the Windows system is constantly updated, the latest Windows 11 system also brings some new changes and functions. One of the common problems is that users cannot find the path to "My Computer" in Win11 system. This was usually a simple operation in previous Windows systems. This article will introduce how the paths of "My Computer" are different in Win11 system, and how to quickly find them. In Windows1
