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

JavaScript DOMContentLoaded event case study

DOMContentLoaded Event Literally, it fires after ...

The difference between KEY, PRIMARY KEY, UNIQUE KEY, and INDEX in MySQL

The problem raised in the title can be broken dow...

MySQL data migration using MySQLdump command

The advantages of this solution are simplicity an...

Use CSS to achieve circular wave effect

I often see some circular wave graphics on mobile...

Sharing several methods to disable page caching

Today, when developing, I encountered a method wh...

Solve the problem of IDEA configuring tomcat startup error

The following two errors were encountered when co...

Complete steps to build a Laravel development environment using Docker

Preface In this article, we will use Docker to bu...

MySQL 8.0.11 installation and configuration method graphic tutorial (win10)

This article records the installation and configu...

Common HTML tag writing errors

We better start paying attention, because HTML Po...

Build a Docker private warehouse (self-signed method)

In order to centrally manage the images we create...

How to clean up the disk space occupied by Docker

Docker takes up a lot of space. Whenever we run c...

Solve the error of installing VMware Tools on Ubuntu 18.04

1. According to the online tutorial, the installa...

How to reasonably use the redundant fields of the database

privot is the intermediate table of many-to-many ...

Guide to using env in vue cli

Table of contents Preface Introduction-Official E...