How to create MySQL database

In this article we are going to create database from the Command Line and using phpMyAdmin.

Creating a MySQL database from the Command Line

Open Command Prompt as Administrator, change the path to the MySQL bin folder cd c:\path\to\the MySQL bin folder
Run this command "mysql -u root -p" then press Enter.
Enter your MySQL Password then press Enter.

In this example we are going to create a MySQL database called "mydb" and Collation type is "utf8_general_ci"

create database mydb default collate utf8_general_ci;

Press Enter to create the database.

To insert tables into the database we must first activate the database by typing "use mydb;" then press Enter, but we will not discuss further about creating tables right now. We just want to create an empty MySQL database. Run the command "show databases" to show database list.

To exit the MySQL command line type in "exit" or "\q" and then press Enter.

For details on how to create a MySQL database from the Command Line see the image below:

Create MySQL Database 03

Creating a MySQL database using phpMyAdmin

Open your browser and type in "http://localhost/phpmyadmin" into the address bar.

Follow the steps as shown below:

1. From the menu list click on "New"
2. Enter the database name,
3. For Collation type select "utf8_general_ci"
4. Click on the "Create" button.

A new database should be created in the database list.

Click on the Image to enlarge it

That's all for now.

No comments:

Post a Comment