Learn Basic MySQL In Linux in 3 Easy Steps

This article intends to teach you basic MySQL in Linux and show you how to install it on different Linux operation systems. In simple words, MySQL is a database management system. By using MySQL you can easily create and manage your databases.

How To Learn Basic MySQL In Linux?

To install MySQL in Linux, you must have access to your server as a root or non-root user with sudo privileges. For this purpose, you can visit the Orcacore website and look for initial server setup guides.

Now follow the steps below to Learn Basic MySQL In Linux.

Step 1 – Install MySQL on Linux

The installation of MySQL is so easy. To do this, we have MySQL installation instructions on different operating systems, you can visit them to see how it works:

Install MySQL on Ubuntu 22.04

Install MySQL on AlmaLinux 9

How To Install MySQL on Centos 7

How To Install MySQL 8.0 on Debian 11

Once you have installed MySQL on your Linux server, you must secure your installation. To do this, follow the steps below.

Step 2 – How To Secure MySQL?

To secure your MySQL installation, you can use a MySQL security script that has been provided by MySQL. To do this, you can run the command below:


This command will ask you some questions. First, you must press enter once and enter the MySQL login password. (default password is empty).

Next, answer the other questions as you wish. It is recommended that answer them by pressing Y.

Step 3 – Basic MySQL In Linux – How To Work with MySQL?

When the installation of MySQL in Linux is finished you can see basic usage of it in the rest of the article.

Access MySQL Shell

At this point, you can access MySQL shell by using the following command:

mysql -u root –p

You should enter the root MySQL password and press enter.

Note: Remember to end your commands with “;”. MySQL commands are usually written in uppercase.

Create and Delete a MySQL Database

You can easily create a database in MySQL in Linux with the following command: Here we named it orcadb, you can choose your desired name.

mysql> CREATE DATABASE orcadb;

Then you can check available databases with the following command:


You can also delete a database easily with the following command:

mysql> DROP DATABASE orcadb;

If you check your available databases there is no more a database named orcadb.

How To Access a MySQL Database?

From your MySQL database, you can put information in your new database. Open your database with the following command:

mysql> USE orcadb;

Then you can see its tables with the following command:

SHOW tables;

Because it is a new database there is nothing to show.

Let’s see how to create a MySQL table for your database.

How To Create a MySQL Table?

You can create a table with the CREATE TABLE command in MySQL shell. For example:

mysql> CREATE TABLE orca (name VARCHAR(20),
age VARCHAR(10),
email VARCHAR(20)

This command will create a table named orca. The table has some variables such as name, age, and email.

You can see tables with the SHOW TABLES command:


How To Add Data to a MySQL Table?

In MySQL in Linux, you can use the format below to put your information into the table:

mysql> INSERT INTO `orca` (`name`, `age`,`email`) VALUES (“user1”,’25’,”user1@com”);

You can look at your table with the following command:


How To Update MySQL Table Data?

You can use the following command to update your information in the table:

mysql> UPDATE `orca` 
`age` = '32' 
WHERE `orca`.`name` ='user1';

How To Add and Delete a MySQL Table Column?

You can easily add a column with the following command:

ALTER TABLE orca ADD lastname VARCHAR(40);

If you want that your column is in a specific place use the command below:

ALTER TABLE orca ADD lastname VARCHAR(40) AFTER name;

You can also delete a column with the following DROP command:

ALTER TABLE orca DROP lastname;

You can easily delete a row with the following command:

DELETE from [table name] where [column name]=[field text];

That’s it, you are done. These are basic MySQL in Linux that everyone must know about it.


At this point, you have learned basic Mysql in Linux including creating tables, adding and deleting columns, etc on Linux.

Hope you enjoy it. You may be interested in the following MySQL articles:

Find MySQL Configuration File Location on Linux

Install MySQL Workbench on Ubuntu 22.04

How To Create a New User on MySQL

Reset MySQL And MariaDB Root Password on Ubuntu 22.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!