O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a New Database

You use the CREATE DATABASE command to create a new database. To create a new database named newdb, issue the following command. The output will be as shown if the database is created successfully.

mysql> CREATE DATABASE newdb;
Query OK, 1 row affected (0.02 sec)

Creating Database

Usually you execute this command when you are connected as the root user, but you can create databases when logged in as any user who has the CREATE privilege. You will learn more about the privilege system in MySQL in Lesson 18, “Managing User Access.”

The database name can be up to 64 characters in length and can contain any character that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required