MySQL Tutorial, Most Common used Commands in MySQL.

MySQL is an open source database management software which helps to save, manage, and fetching information. It is a very highly effective program with a lot of flexibility.

This article is about the easiest guide and most commonly used commands in MySQL.

How to Install MySQL on Ubuntu and CentOS

Ubuntu

CentOS

How to Access the MySQL shell

Once MySQL is installed, then to access MySQL shell we can use following command on terminal.

Now enter MySQL root password into the prompt, and then we are into the MySQL shell and we are ready to perform MySql commands on the shell.

Important Notes:
– All MySQL commands end with a semicolon(;), if the phrase does not end with a semicolon, the command will not perform or execute.
– Although it is not necessary, MySQL commands are usually written in uppercase and databases, tables, usernames, or text are in lowercase to make them simpler to differentiate. However, the MySQL command line is not case sensitive.

How to Create and Delete a MySQL Database

Syntax to quickly examine what databases are available by typing following command on shell.

Output of above command:

Syntax for Creating a database:

In our case ‘events’ is our new database;

Delete or Drop Database

Access a MySQL Database

Once we have created new database, then we can open or access database by following command:

In the same way we can check tables in the database:

Create a MySQL Table

Let’s create a new MySQL table:

Let’s see how the table seems to be within the database using the “SHOW TABLES;” command:

We can check table structure using following command:

Insert Values to a MySQL Table

Use this syntax to insert new row into the table:

Output of above command:

Fetch values from table:

Update Row in the Table

This command can be also used for add new value into specific cells, if cell empty.

Add and Delete a Column

1. Add Column to Table:

2. Delete Column from Table:

Delete a Row from table

Leave a Reply

Your email address will not be published. Required fields are marked *