Here we are highlighting a few easy steps to create a database table in MySQL Server via Command Line.

1. Open the MySQL Server Command Line Client window, and enter the username and password.

2. Now we select the schema under which we want to create our database table. For example here in this post we are considering the default schema ‘world’ provided by MySQL Server by using the command.

mysql> use world

3. Then we create the database table named ‘student_db’ using the following command.

mysql> create table student_db (id int, name varchar(25), age int, sex varchar(1), class varchar(4), grade varchar(10) );

4. After the database table is created we intend to enter some meaningful data to it, using the next set of commands given below.

mysql> insert into student_db values (1, 'amit', 17, 'M', '8B', 'A+');
mysql> insert into student_db values (2, 'sneha', 20, 'F', '11A', 'A++');

5. And now, to check if the data which has been entered correctly or not and also to show the database table we use the following command.

mysql> select * from student_db;
+--------+-------------+------+-----+----+
| id  | name | age  | sex | class | grade|
+-----+------+------+-----+-------+------+
| 1   | amit |  17  |  M  |  8B   |  A+  |
| 2   |sneha |  20  |  F  |  11A  |  A++ |         
+-----+------+------+-----+-------+-------
2 rows in set (0.00 sec)
create table in mysql

Create database and table in MySQL