首次使用MySQL无法创建Schema数据库,求助解决1064语法错误
Hey there, let's fix that syntax error you're hitting! The problem here is the single quotes you're using around your database name.
In MySQL, identifiers like database names, table names, or column names need to be wrapped in backticks (`) if they contain special characters, spaces, or are reserved words. If your database name follows standard naming rules (starts with a letter, no spaces, no special characters), you don't even need any quotes at all.
Your original code used single quotes, which MySQL doesn't accept for identifiers:
CREATE SCHEMA 'database123';
Here are the two correct ways to write this statement:
- Without any quotes (since
database123is a valid standard name):CREATE SCHEMA database123; - Using backticks (a safe practice if you might use non-standard names later):
CREATE SCHEMA `database123`;
Quick side note: In MySQL, CREATE SCHEMA and CREATE DATABASE are completely interchangeable—either command will create a database for you.
内容的提问来源于stack exchange,提问作者albertjohnsonquaye

