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

Let's talk about the difference between containers and images in Docker

What is a mirror? An image can be seen as a file ...

HTML+CSS merge table border sample code

When we add borders to table and td tags, double ...

Vue.js implements image switching function

This article shares the specific code of Vue.js t...

Detailed explanation of the basic use of react-navigation6.x routing library

Table of contents react-native project initializa...

Detailed explanation of MySQL execution plan

The EXPLAIN statement provides information about ...

Detailed explanation of how to use the Vue license plate input component

A simple license plate input component (vue) for ...

Example of how to implement underline effects using Css and JS

This article mainly describes two kinds of underl...

How to use bind to set up DNS server

DNS (Domain Name Server) is a server that convert...

Detailed explanation of loop usage in javascript examples

I was bored and sorted out some simple exercises ...

Django2.* + Mysql5.7 development environment integration tutorial diagram

environment: MAC_OS 10.12 Python 3.6 mysql 5.7.25...