There are several ways to create a MySQL database. The most common way to create MySQL database is to use the functions located in your cpanel. Alternative ways exist such as interfacing with the MySQL database itself or using third party programs such as phpMyAdmin. You could even create a MySQL database using a programming language such as PHP. Each of the following can be used to create a MySQL database.
Using a database client to create a MySQL database
To create a MySQL database using a database client, log into your server and when you get to the command prompt, type the following:
CREATE DATABASE dbname
dbname is the name of the database you would like to create. If the database is created correctly, you’ll receive a confirmation message. Once the database is created, you can add tables as follows:
CREATE TABLE tablename
This query would create a MySQL database named tablename with the following fields: myid, myname, and myusername. INT and VARCHAR are the column types and the type of data these columns will hold.
To create a MySQL database using cPanel
Log into your cpanel and select the “MySQL Databases” link. First you’ll want to create the database by entering the name of the new database. Then simply click the “Create Database” button. You’ve just created a new database.
To create a MySQL database using PHP
Many PHP programs install a database on their first run. If you need to create a MySQL database using code, you’ll need to use the following code:
The first line after the opening tag is just the connection to the database. The format for mysql_connect function is host, user, and pass. The next line in our PHP script starts with an if statement. The if statement just checks to see of the mysql_create_db function returns true. If the function returns true and creates the MySQL database “database_name” ok, then “Database Created!” is printed to the screen. Otherwise, we get the error message.
You can also create a MySQL database using phpMyAdmin
Once logged into phpMyAdmin, you’ll see a link that allows you to create a new database. Once you’ve entered all the information click create database and you’re all set. Once the MySQL database is created, it will be shown on the left pane of phpMyAdmin.
There are other third party programs that can create a MySQL database, the choice to which one you use is totally up to you.