Table of Contents
Table of Contents
Before learning about MySQL, it’s important to understand what an RDBMS is. RDBMS stands for Relational Database Management System. It’s a system that organizes data into tables, where each table is made up of rows and columns. These tables are connected through relationships, which show how the data in different tables is related to each other. This makes it easier to see and manage the connections between different pieces of information.
MySQL is the world’s most popular open source database. It’s a relational database management system (RDBMS) developed by Oracle that is based on structured query language (SQL).
This tutorial covers the MySQL database running on a Linux server. This tutorial will also cover the generation and use a simple database. The interface language of the MySQL database is the standard SQL (Standard Query Language) which allows for inserts, updates and queries of data stored in relational tables.
The SQL language is also used for the administration of the database for the creation and modification of tables, users and access privileges. Tables are identified by unique names and hold data in a row and column (record) structure. A fixed number of named columns are defined for a table with a variable number of rows.
MySQL is a popular choice for managing relational databases for several key reasons are given below.
Step 1: Update Your System
Before installing MySQL, make sure your system is up to date. To do this, run the following commands
sudo apt update
This command updates the list of available packages and their versions.
Step 2: Install MySQL
Now, you can install MySQL by running the command
sudo apt install mysql-server
This command installs the MySQL server on your system. You’ll be prompted to enter your password. Type it in and press ENTER. When asked if you want to continue with the installation, press Y and then ENTER.
After the installation is complete, you can check if MySQL was installed correctly and see which version was installed. Run the command mysql –version in your terminal.
mysql --version
Create a first database
create a database named testdb . In order to do that, log in to the MySQL console with the command
sudo mysql -u root
Let’s create a database using the following command:
CREATE DATABASE testdb;
To see the database created use the following command:
show databases;
Create a new database user with permissions
Next, create a user with permission to access the new database. In this example, create the user dbuser with the command:
CREATE USER ‘dbuser’@’localhost’ IDENTIFIED BY ‘PASSWORD’;
When you create a new user, the user doesn’t automatically have access to the database.
Give the user access to the database with the command:
GRANT ALL ON testdb.* To ‘dbuser’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
Quit
Once you install a database, you can use your database server to work with all types of applications and services.
Some of The Most Important SQL Commands
● SELECT – extracts data from a database
● UPDATE – updates data in a database
● DELETE – deletes data from a database
● INSERT INTO – inserts new data into a database
● CREATE DATABASE – creates a new database
● ALTER DATABASE – modifies a database
● CREATE TABLE – creates a new table
● ALTER TABLE – modifies a table
● DROP TABLE – deletes a table
● CREATE INDEX – creates an index (search key)
● DROP INDEX – deletes an index
MySQL is a strong and flexible open-source database system. Its reliability, ability to grow with your needs, fast performance, and compatibility with many tools make it popular in many industries, including e-commerce, healthcare, and social media.
Thanks to its solid security features and broad support, MySQL continues to be a key tool for effectively managing and handling data today.
Visit Flexicloud to discover more about our comprehensive plans and diverse features, designed to meet all your cloud computing needs