Creating a new database in MYSQL

Here, you will learn how to create a new database in MySql, add a table to the database, and add data to the table. You will also learn how to query databases and tables, update data in tables, and delete data, tables, and databases.

Creating a New Database

It is easy to create a new MySQL database.Open a shell prompt, change to the correct folder (if using Windows or Mac OS X), and then on Ubuntu or Windows type:

mysql -u root -p

On the Mac type:

/mysql -u root -p

Press Enter. Now enter the root password you specified earlier, and press Enter again. You should see the prompt appear:

mysql >

To create a new database, you need to use the CREATE DATABASE command. Type the following to create a new database called mydatabase :

CREATE DATABASE mydatabase;

Press Enter and MySQL creates your new database.

You can also see a list of all the databases in the system including your new database by typing the command SHOW DATABASES :

mysql > SHOW DATABASES;