Example of how to create a database name with special characters in MySQL

Example of how to create a database name with special characters in MySQL

Preface

This article explains how to create a database name with special characters in MySQL. The special characters here include: !@#$%^

Here’s how

Use backticks ` to enclose the database name (quotation marks are not allowed). In the English input method state, press the Esc key to display the corresponding key below. Of course, if you do not use backticks to enclose the database name, an error will be reported if the database name contains special characters.

For example, using the following create command will result in an error:

mysql> CREATE DATABASE www.mafutian.net DEFAULT CHARSET UTF8;
1064 - Change the syntax of '.mafutian.net DEFAULT CHARSET UTF8' to the string 1

The correct way to create it:

mysql> CREATE DATABASE `www.mafutian.net` DEFAULT CHARSET UTF8;
Query OK, 1 row affected

As shown below:

Another example:

mysql> CREATE DATABASE `!@#$%^&*()_+.` DEFAULT CHARSET UTF8;
Query OK, 1 row affected
mysql> USE !@#$%^&*()_+.
 -> ;
1064 - I have read the syntax of '!@#$%^&*()_+.' to the letter 1
mysql> USE `!@#$%^&*()_+.`;
Database changed
mysql> SELECT database();
+---------------+
| database() |
+---------------+
| !@#$%^&*()_+. |
+---------------+
1 row in set

As can be seen from the above, when selecting a database, you also need to use backticks ` to quote the database name. As shown below:

Similarly, when deleting a database, you also need to use backticks to quote the database name:

mysql> DROP DATABASE `www.mafutian.net`;
Query OK, 0 rows affected
mysql> DROP DATABASE `!@#$%^&*()_+.`;
Query OK, 0 rows affected

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • View, create and modify the encoding format of database and data table in MySQL
  • Two ways to create a MySQL database
  • MySQL commands for creating and deleting databases and related PHP script operations
  • MySQL Basic Database Creation
  • How to create a MySQL database (de1) using commands

<<:  JavaScript jigsaw puzzle game

>>:  A brief analysis of Docker private image library and Alibaba Cloud object storage OSS

Recommend

Application example tutorial of key in Vue page rendering

introduction During the front-end project develop...

Join operation in Mysql

Types of joins 1. Inner join: The fields in the t...

A mobile adaptive web page effect solves the problem of small display page

For work needs, I need to make a mobile phone adap...

Vue implements sending emoticons in chat box

The specific code for sending emoticons in the vu...

How to install MySQL 5.7 from source code in CentOS 7 environment

This article describes how to install MySQL 5.7 f...

How to set utf-8 encoding in mysql database

Modify /etc/my.cnf or /etc/mysql/my.cnf file [cli...

In-depth analysis of the Identifier Case Sensitivity problem in MySQL

In MySQL, you may encounter the problem of case s...

Steps to enable TLS in Docker for secure configuration

Preface I had previously enabled Docker's 237...

Detailed steps for IDEA to integrate docker to achieve remote deployment

1. Enable remote access to the docker server Log ...

Detailed explanation of how MySQL solves phantom reads

1. What is phantom reading? In a transaction, aft...

Vue two same-level components to achieve value transfer

Vue components are connected, so it is inevitable...

How to deploy services in Windows Server 2016 (Graphic Tutorial)

introduction Sometimes, if there are a large numb...

Use semantic tags to write your HTML compatible with IE6,7,8

HTML5 adds more semantic tags, such as header, fo...

Detailed explanation of Bind mounts for Docker data storage

Before reading this article, I hope you have a pr...

How to deploy Angular project using Docker

There are two ways to deploy Angular projects wit...