-2

I tried to create Database with:

CREATE DATABASE 'mynewdb';

and got:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''mynewdb'' at line 1

Why? What did I wrong?

Taz
  • 3,718
  • 2
  • 37
  • 59
not rly
  • 1
  • 1

2 Answers2

0

Don't use quotes:

CREATE DATABASE mynewdb;
ThoriumBR
  • 930
  • 12
  • 25
-1

You have to remove your quotes or use backticks such:

CREATE DATABASE mynewdb;

or

CREATE DATABASE `mynewdb`;

Backticks are to be used for database, table and column identifiers, but are only necessary when the identifier is a MySQL reserved keyword, or when the identifier contains whitespace characters or characters beyond a limited set (see below) It is often recommended to avoid using reserved keywords as column or table identifiers when possible, avoiding the quoting issue.


Here a very good answer When to use single quotes, double quotes, and backticks in MySQL.

Kevin Wenger
  • 1,484
  • 1
  • 13
  • 29
  • If you believe that the current question already has already been answered by another question here on O, then pls mark it as a duplicate, do not answer! – Shadow Sep 04 '17 at 12:17