MySQL password contains special characters & operation of logging in from command line

MySQL password contains special characters & operation of logging in from command line

On the server, in order to quickly log in to the database, we usually use mysql -hhost -uusername -ppassword db to log in to the database. If there is no special character & in the password, it will directly enter the database sql command line. If there is a special character &, the following prompt will appear:

-bash: syntax error near unexpected token `&'

Generally, we can use the command mysql -hhost -uusername -p db and then manually enter the password according to the prompts.

In addition, passwords with special characters can be processed here.

1. Simply enclose the password in single quotes.

2. Add '\' before the special character & to log in.

Supplement: MySQL sets a complex password containing $ special symbols, which makes it impossible to log in with the command

For security reasons, the $ special symbol was added when setting the MYSQL password, resulting in the following error when running the script:

After some trouble, I found out that it was $

Change the password to remove $

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Solution to the problem that MySQL commands cannot be entered in Chinese
  • Detailed explanation of encoding issues during MySQL command line operations
  • Introduction to the use of MySQL source command
  • MySQL commonly used SQL and commands from entry to deleting database and running away
  • Implementation of mysql using mysqlbinlog command to restore accidentally deleted data
  • Introduction to query commands for MySQL stored procedures
  • Three methods of automatically completing commands in MySQL database
  • Mysql desktop tool SQLyog resources and activation methods say goodbye to the black and white command line
  • MySQL login and exit command format
  • How to use the MySQL authorization command grant
  • Summary of MySQL basic common commands

<<:  CSS Summary Notes: Examples of Transformations, Transitions, and Animations

>>:  Use Vue3 for data binding and display list data

Recommend

Are the value ranges of int(3) and int(10) the same in mysql

Table of contents Question: answer: Reality: Know...

mySql SQL query operation on statistical quantity

I won't say much nonsense, let's just loo...

MySQL Series 10 MySQL Transaction Isolation to Implement Concurrency Control

Table of contents 1. Concurrent access control 2....

Steps to build the vite+vue3+element-plus project

Use vite to build a vue3 project You can quickly ...

How to deploy and start redis in docker

Deploy redis in docker First install Docker in Li...

How to configure VMware virtual machine NAT mode

This article describes the VMware virtual machine...

Detailed process of using nginx to build a webdav file server in Ubuntu

Install nginx Note that you must install nginx-fu...

How to limit the number of concurrent connection requests in nginx

Introduction The module that limits the number of...

Detailed steps to install web server using Apache httpd2.4.37 on centos8

Step 1: yum install httpd -y #Install httpd servi...

Vue shopping cart case study

Table of contents 1. Shopping cart example 2. Cod...

MySQL 5.6.33 installation and configuration tutorial under Linux

This tutorial shares the installation and configu...

Summary of the use of Vue computed properties and listeners

1. Computed properties and listeners 1.1 Computed...

Detailed explanation of common methods of Vue development

Table of contents $nextTick() $forceUpdate() $set...

How to install docker under centos and remotely publish docker in springboot

Table of contents 1. Installation of JDK1.8 under...