Create/Delete the Database Tables Through The Terminal In Linux/Ubuntu



If you want to Create or Delete the Database tables and wants to perform the general operation in database. Here is the general commands for performing the operations in database tables.

Show Databases

Step 1. Open the terminal.
Step 2. Login through the SSH

ssh {user_name}@{host_name}

Step 3. Press Enter then it will ask for the Password after entering the Password you will be logged in.
Step 4. Now run the below command

mysql -u {database_username} -p {database_name}

After press the Enter buttons it will ask for the Password, after putting the password it will enter you into the database environment.

mysql> show databases;

it will display all the database, the result will be

+————————-+
| Database                       |
+————————-+
| information_schema |
| XYZ                                |
| XYZ_blog                      |
| Abc_blog_old              |
| yahoo_old                     |
| mysql                             |
+————————-+

If there are more than one database then select the database in which you want to perform the operation, by using the below command you can select the database

mysql use {Database Name};

Now you are able to perform the operations in the selected database

Delete the Database/Table from the selected database

Drop Database table:

mysql> drop table {table name};

Drop Database:

mysql> drop database {database name};

Create the Database

mysql> create database {database name};

Hope this will help to someone.