MySQL Command in Linux


MySQL is an open-source relational database management system (RDBMS). Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language.

Environment

I will operate the MySQL Server 5.7 in Ubuntu 16.04.

Linux Commands

Install MySQL client:

Connect the remote MySQL cluster:

For security, you aren’t allowed to enter the password with the parameter -p.

MySQL Commands

The SQL in MySQL is case insensitive.

Check the status of MySQL Server:

Create a database:

View all database:

Delete a database:

Change the using database:

View the using database:

Show all tables of one database:

Create a table with at least one column:

Show the status of table:

Add a column to table:

Change the data type of column:

Change the column name and data type:

Add a row to table:

Select the rows with specific fields from a table:

Change the specific field of rows that fulfill the condition that the value is null:

Delete records in a table:

Using the wildcard pattern to select the rows from table:

% symbol matches any length of any character.
_ symbol matches one character.

Select the rows contain one of the values(1 & 5):

Select the rows whose the value of specific field is inside the range [0-10]:

Show the warning of the last command:

Select the min value of the field with the alias name from the table:

Select some rows meet the condition and calculate the sum of the values of fields, return with random fields:

Select three of all rows in default order from one table:

Return the number of the rows satisfy the condition with a random fields:

Leave a Reply

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